private void InitStablizingOrder(List <BlockSet> stablizerChain)
            {
                StablizingOrder = new List <int>();

                foreach (var bs in stablizerChain)
                {
                    foreach (var idx in bs.Indexes)
                    {
                        var block    = bs.State.Blocks[idx];
                        var position = block.Position;

                        foreach (CubeState.Axis axis in Enum.GetValues(typeof(CubeState.Axis)))
                        {
                            foreach (CubeState.Direction direction in Enum.GetValues(typeof(CubeState.Direction)))
                            {
                                var color = block.Colors[(int)axis, (int)direction];
                                if (CubeState.Color.None == color)
                                {
                                    continue;
                                }

                                int actionMapIndex = ActionMap.ColorBlockToIndex(position, axis, direction);
                                StablizingOrder.Add(actionMapIndex);
                            }
                        }
                    }
                }

                VerifyStablizingOrder();
            }
            private static bool ActionMap_Change(ActionMap __instance, ref int no)
            {
                if (IsStudio)
                {
                    return(true);
                }
                if (StudioSceneFile == null)
                {
                    return(true);
                }

                Singleton <Studio.Studio> .Instance.LoadScene(StudioSceneFile);

                StudioMapNo = Singleton <Studio.Studio> .Instance.sceneInfo.map;

                //Because the map IDs in the Studio list files don't match the Map list files
                //Todo: Sideloader map support
                if (Studio.Info.Instance.dicMapLoadInfo.TryGetValue(StudioMapNo, out var mapLoadInfo))
                {
                    foreach (var x in __instance.infoDic)
                    {
                        if (x.Value.AssetBundleName == mapLoadInfo.bundlePath && x.Value.AssetName == mapLoadInfo.fileName)
                        {
                            StudioMapNo = x.Key;
                        }
                    }
                }

                no = StudioMapNo;
                Traverse.Create(__instance).Property("no").SetValue(StudioMapNo);
                return(false);
            }
Example #3
0
        private static void OnMapChangedHook(ActionMap __instance)
        {
            if (__instance.mapRoot == null || __instance.isMapLoading)
            {
                return;
            }

            var created = 0;

            foreach (var iconEntry in _entries)
            {
                if (iconEntry.MapNo == __instance.no)
                {
                    try
                    {
                        SpawnActionPoint(iconEntry, created);
                        created++;
                    }
                    catch (Exception e)
                    {
                        KoikatuAPI.Logger.LogError($"Failed to created custom action point on map no {__instance.no} at {iconEntry.Position}\n{e}");
                    }
                }
            }

            if (created > 0)
            {
                KoikatuAPI.Logger.LogDebug($"Created {created} custom action points on map no {__instance.no}");
            }
        }
        public void initialize()
        {
            ActionMap map = new ObjectCreator("ActionMap").Create();

            map.bindCmd("keyboard", "escape", "ToolsToolbarArray->WorldEditorInspectorPalette.performClick();", "");
            map.bindCmd("keyboard", "1", "ShapeEditorNoneModeBtn.performClick();", "");
            map.bindCmd("keyboard", "2", "ShapeEditorMoveModeBtn.performClick();", "");
            map.bindCmd("keyboard", "3", "ShapeEditorRotateModeBtn.performClick();", "");
            //%map.bindCmd( keyboard, "4", "ShapeEditorScaleModeBtn.performClick();", "" ); // not needed for the shape editor
            map.bindCmd("keyboard", "n", "ShapeEditorToolbar->showNodes.performClick();", "");
            map.bindCmd("keyboard", "t", "ShapeEditorToolbar->ghostMode.performClick();", "");
            map.bindCmd("keyboard", "r", "ShapeEditorToolbar->wireframeMode.performClick();", "");
            map.bindCmd("keyboard", "f", "ShapeEditorToolbar->fitToShapeBtn.performClick();", "");
            map.bindCmd("keyboard", "g", "ShapeEditorToolbar->showGridBtn.performClick();", "");
            map.bindCmd("keyboard", "h", "ShapeEdSelectWindow->tabBook.selectPage( 2 );", ""); // Load help tab
            map.bindCmd("keyboard", "l", "ShapeEdSelectWindow->tabBook.selectPage( 1 );", ""); // load Library Tab
            map.bindCmd("keyboard", "j", "ShapeEdSelectWindow->tabBook.selectPage( 0 );", ""); // load scene object Tab
            map.bindCmd("keyboard", "SPACE", "ShapeEdAnimWindow.togglePause();", "");
            map.bindCmd("keyboard", "i", "ShapeEdSequences.onEditSeqInOut(\"in\", ShapeEdSeqSlider.getValue());", "");
            map.bindCmd("keyboard", "o", "ShapeEdSequences.onEditSeqInOut(\"out\", ShapeEdSeqSlider.getValue());", "");
            map.bindCmd("keyboard", "shift -", "ShapeEdSeqSlider.setValue(ShapeEdAnimWindow-->seqIn.getText());", "");
            map.bindCmd("keyboard", "shift =", "ShapeEdSeqSlider.setValue(ShapeEdAnimWindow-->seqOut.getText());", "");
            map.bindCmd("keyboard", "=", "ShapeEdAnimWindow-->stepFwdBtn.performClick();", "");
            map.bindCmd("keyboard", "-", "ShapeEdAnimWindow-->stepBkwdBtn.performClick();", "");

            this.map = map;

            this.initSettings();
        }
        public void Setup()
        {
            gameMap              = GameMapUTests.CreateTestGameMap();
            player1              = PlayerUTests.CreateTestPlayer(1);
            player2              = PlayerUTests.CreateTestPlayer(2);
            player1Camera        = MapCameraUTests.CreateTestMapCamera();
            player2Camera        = MapCameraUTests.CreateTestMapCamera();
            player1.gameMap      = gameMap;
            player2.gameMap      = gameMap;
            player1.playerCamera = player1Camera;
            player2.playerCamera = player2Camera;

            actionMap       = player1.actionMap;
            unit1           = UnitCardUnitITests.CreateTestUnitWithCard();
            unit2           = UnitCardUnitITests.CreateTestUnitWithCard();
            unit1.player    = player1;
            unit2.player    = player2;
            hexCoords       = new Vector3Int(0, 0, 0);
            targetHexCoords = new Vector3Int(1, -1, 0);
            mousePosition   = gameMap.HexToWorldCoords(hexCoords);
            player1Camera.MoveCameraToPosition(mousePosition);
            player2Camera.MoveCameraToPosition(mousePosition);
            gameMap.AddPiece(unit1, hexCoords);

            // Get center hex
            gameHex = gameMap.GetWorldPositionHex(Vector3Int.zero);
        }
        public override void onSleep()
        {
            ActionMap moveMap = "moveMap";

            // pop the keymaps
            moveMap.pop();
        }
Example #7
0
    void UpdateActionMapScript()
    {
        ActionMap     original  = (ActionMap)serializedObject.targetObject;
        string        className = GetCamelCaseString(original.name, true);
        StringBuilder str       = new StringBuilder();

        str.AppendFormat(@"using UnityEngine;
using UnityEngine.InputNew;

// GENERATED FILE - DO NOT EDIT MANUALLY
public class {0} : ActionMapInput {{
	public {0} (ActionMap actionMap) : base (actionMap) {{ }}
	
", className);

        for (int i = 0; i < m_ActionMapEditCopy.actions.Count; i++)
        {
            Type   controlType = m_ActionMapEditCopy.actions[i].controlData.controlType;
            string typeStr     = controlType.Name;
            str.AppendFormat("	public {2} @{0} {{ get {{ return ({2})this[{1}]; }} }}\n", GetCamelCaseString(m_ActionMapEditCopy.actions[i].name, false), i, typeStr);
        }

        str.AppendLine(@"}");

        string path = AssetDatabase.GetAssetPath(original);

        path = path.Substring(0, path.Length - Path.GetExtension(path).Length) + ".cs";
        File.WriteAllText(path, str.ToString());
        AssetDatabase.ImportAsset(path);

        original.SetMapTypeName(className + ", " + "Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");
    }
Example #8
0
 void SetAction(Action set, ActionMap action)
 {
     if (!ActionLock.Contains(action))
     {
         set();
     }
 }
Example #9
0
        public static ActionMap[] ResetActionsToDefault()
        {
            ActionMap[] actionMaps = new ActionMap[Enum.GetNames(typeof(Actions)).Length];

            actionMaps[(int)Actions.OK]               = new ActionMap();
            actionMaps[(int)Actions.OK].key           = Keys.X;
            actionMaps[(int)Actions.OK].gamePadButton = GamePadButtons.A;

            actionMaps[(int)Actions.Cancel]               = new ActionMap();
            actionMaps[(int)Actions.Cancel].key           = Keys.C;
            actionMaps[(int)Actions.Cancel].gamePadButton = GamePadButtons.B;

            actionMaps[(int)Actions.Up]               = new ActionMap();
            actionMaps[(int)Actions.Up].key           = Keys.Up;
            actionMaps[(int)Actions.Up].gamePadButton = GamePadButtons.Up;

            actionMaps[(int)Actions.Down]               = new ActionMap();
            actionMaps[(int)Actions.Down].key           = Keys.Down;
            actionMaps[(int)Actions.Down].gamePadButton = GamePadButtons.Down;

            actionMaps[(int)Actions.Left]               = new ActionMap();
            actionMaps[(int)Actions.Left].key           = Keys.Left;
            actionMaps[(int)Actions.Left].gamePadButton = GamePadButtons.Left;

            actionMaps[(int)Actions.Right]               = new ActionMap();
            actionMaps[(int)Actions.Right].key           = Keys.Right;
            actionMaps[(int)Actions.Right].gamePadButton = GamePadButtons.Right;

            actionMaps[(int)Actions.Pause]               = new ActionMap();
            actionMaps[(int)Actions.Pause].key           = Keys.Space;
            actionMaps[(int)Actions.Pause].gamePadButton = GamePadButtons.Start;

            return(actionMaps);
        }
Example #10
0
        //[SerializeField]
        //private UI.HUD _hud;

        public void Awake()
        {
            _actionMap = new ActionMap();
            World.Room.OnCharacterStartStaticHandler += OnCharacterStart;

            //UI.HUD.OnHUDStartStaticHandler += OnHUDStart;
        }
        public override void onWake()
        {
            ActionMap moveMap = "moveMap";

            // just update the action map here
            moveMap.push();
        }
Example #12
0
        public void initialize()
        {
            ObjectCreator oc_Newobject3 = new ObjectCreator("SimSet", "ForestTools");

            ObjectCreator oc_Newobject2 = new ObjectCreator("ForestBrushTool");

            oc_Newobject2["internalName"] = "BrushTool";
            oc_Newobject2["toolTip"]      = "Paint Tool";
            oc_Newobject2["buttonImage"]  = "tools/forest/images/brushTool";

            oc_Newobject3["#Newobject2"] = oc_Newobject2;

            ObjectCreator oc_Newobject1 = new ObjectCreator("ForestSelectionTool");

            oc_Newobject1["internalName"] = "SelectionTool";
            oc_Newobject1["toolTip"]      = "Selection Tool";
            oc_Newobject1["buttonImage"]  = "tools/forest/images/selectionTool";
            oc_Newobject3["#Newobject1"]  = oc_Newobject1;

            oc_Newobject3.Create();

            ActionMap map = new ObjectCreator("ActionMap").Create();

            map.bindCmd("keyboard", "1", "ForestEditorSelectModeBtn.performClick();", "");        // Select
            map.bindCmd("keyboard", "2", "ForestEditorMoveModeBtn.performClick();", "");          // Move
            map.bindCmd("keyboard", "3", "ForestEditorRotateModeBtn.performClick();", "");        // Rotate
            map.bindCmd("keyboard", "4", "ForestEditorScaleModeBtn.performClick();", "");         // Scale
            map.bindCmd("keyboard", "5", "ForestEditorPaintModeBtn.performClick();", "");         // Paint
            map.bindCmd("keyboard", "6", "ForestEditorEraseModeBtn.performClick();", "");         // Erase
            map.bindCmd("keyboard", "7", "ForestEditorEraseSelectedModeBtn.performClick();", ""); // EraseSelected
            map.bindCmd("keyboard", "8", "ForestEditorDropToGroundModeBtn.performClick();", "");  // DropTheBeat
            //%map.bindCmd( keyboard, "backspace", "ForestEditorGui.onDeleteKey();", "" );
            //%map.bindCmd( keyboard, "delete", "ForestEditorGui.onDeleteKey();", "" );
            this.map = map;
        }
Example #13
0
        public static void GetBindingDictionaryFromActionMap(ActionMap actionMap, BindingDictionary bindingDictionary)
        {
            var actions = actionMap.actions;

            foreach (var scheme in actionMap.controlSchemes)
            {
                var bindings = scheme.bindings;
                for (var i = 0; i < bindings.Count; i++)
                {
                    var binding = bindings[i];
                    var action  = actions[i].name;
                    List <VRInputDevice.VRControl> controls;
                    if (!bindingDictionary.TryGetValue(action, out controls))
                    {
                        controls = new List <VRInputDevice.VRControl>();
                        bindingDictionary[action] = controls;
                    }

                    foreach (var source in binding.sources)
                    {
                        bindingDictionary[action].Add((VRInputDevice.VRControl)source.controlIndex);
                    }
                }
            }
        }
Example #14
0
        private string GetDebugName(ActionMap map, ActionParsed parsed)
        {
            if (map != parsed.ActionMap)
                throw new Exception("There are errors in one of the methods: GetCurrentMethodMap() or GetCurrentMethodResult()");

            var specification = CommandParserUtils.GetMethodSpecification(parsed);
            return this.GetType().Name + "." + specification;
        }
Example #15
0
    /*
     * Unity Events
     */

    void Awake()
    {
        nearbyUnits     = new Neighbours <Steering, Steering>(GetComponent <Steering>());
        nearbyBuildings = new Neighbours <Unit, Building>(this);
        statusMap       = new StatusMap(this);
        actionMap       = new ActionMap(this);
        actionMap.add(0, new Ability(fireAbility, 0.1f));
    }
 /// <summary>
 ///     Reload default controls scheme
 /// </summary>
 public void SetDefaultControls()
 {
     Controls = new ActionMap <EControls>();
     SetControl(EControls.TilePressed, KeyCode.Mouse0);
     SetControl(EControls.TileFlagPressed, KeyCode.Mouse1);
     SetControl(EControls.TileSquarePressed, KeyCode.Mouse2);
     SetControl(EControls.GameEscape, KeyCode.Escape);
 }
Example #17
0
 /// <summary>
 /// Initialize
 /// </summary>
 /// <param name="name">Action name</param>
 /// <param name="actionMap">Action map</param>
 /// <param name="argumentRawOfAction">ArgumentRaw where the name of this action was found.</param>
 /// <param name="level">Position (between actions) where this action was found on the command line</param>
 public ActionParsed(string name, ActionMap actionMap, ArgumentRaw argumentRawOfAction, int level)
 {
     this.Name = name;
     this.ArgumentRawOfAction = argumentRawOfAction;
     this.ActionMap           = actionMap;
     this.argumentsRaw        = new List <ArgumentRaw>();
     this.Level = level;
 }
Example #18
0
        public static void Init()
        {
            Core.Console.Profiles.Init();
            Core.Console.Console.Init();
            ActionMap globalActionMap = Sim.FindObjectByName <ActionMap>("GlobalActionMap");

            globalActionMap.bindCmd("keyboard", "tilde", "toggleConsole(true);");
        }
Example #19
0
    public void Start()
    {
        MAXV  = 4f;
        ACCEL = 6f;
        base.Start();

        actionMap = new ActionMap(this);
        actionMap.add(ATTACK, new Ability(1.6f));
    }
        public void TestNotAdded()
        {
            var am    = new ActionMap <int, int>();
            int value = 0;

            am.OnAdd(1, x => value = x);
            am.Add(2, 2);
            Assert.Equal(0, value);
        }
Example #21
0
        /// <summary>
        /// Read one XML element
        ///
        /// <name attr="">
        ///   [ Xelement ]
        /// </name>
        ///
        /// </summary>
        /// <param name="xr">An XML reader @ StartElement</param>
        /// <returns>True if reading can continue</returns>
        private Boolean ReadElement(XmlReader xr)
        {
            Dictionary <String, String> attr = new Dictionary <string, string>( );
            String eName = xr.Name;

            switch (xr.NodeType)
            {
            case XmlNodeType.Element:
                //Console.Write( "<{0}", xr.Name );
                while (xr.MoveToNextAttribute( ))
                {
                    attr.Add(xr.Name, xr.Value); // save the attributes
                    //Console.Write( " {0}='{1}'", xr.Name, xr.Value );
                }
                // now here we could have an actionmap start
                if (m_state == EState.idle)
                {
                    if (m_nodeNameStack.Peek( ).ToLower( ) == "actionmap")
                    {
                        // check for a valid one
                        String mapName = attr["name"];
                        String item    = Array.Find(ActionMapsCls.ActionMaps, delegate(String sstr) {
                            return(sstr == mapName);
                        });
                        if (!String.IsNullOrEmpty(item))
                        {
                            // finally.... it is a valid actionmap
                            m_currentMap      = new ActionMap( );
                            m_currentMap.name = mapName;
                            m_aMap.Add(mapName, m_currentMap); // add to our inventory
                            m_state = EState.inActionMap;      // now we are in and processing the map
                        }
                    }
                }
                else if (m_state == EState.inActionMap)
                {
                    // processing a valid action map - collect actions
                    if (eName.ToLower( ) == "action")
                    {
                        // this is an action.. - collect it
                        CollectActions(attr);
                        ReadActionSub(xr, attr["name"], ""); // a non empty action element may have a sub element (but no device yet)
                    }
                }
                //Console.Write( ">\n" );
                break;

            case XmlNodeType.Text:
                //Console.Write( xr.Value );
                break;

            case XmlNodeType.EndElement:
                //Console.Write( "</{0}>\n", xr.Name );
                break;
            }
            return(true);
        }
Example #22
0
        public override void Execute(UMLRelationship r, ActionMap map, List<PreFile> prefiles)
        {
            UMLClass a = null;
            UMLClass b = null;
            UMLClass ac = null;
            int defaultDetsA = 0;
            int defaultDetsB = 0;
            PreFile prefA;
            PreFile prefB;
            PreRET temp;

            RelationshipHelper.GetClasses(r, ref a, ref b, this.IsAlternate, ref defaultDetsA, ref defaultDetsB);


            if (r is UMLAssociation)
            {
                ac = ((UMLAssociation)r).AssociationClass;
            }

            prefA = PreFileHelper.GetPreFileWithClass(a, prefiles);
            prefB = PreFileHelper.GetPreFileWithClass(b, prefiles);

            if (prefA == null)
            {
                if (prefB == null)
                {
                    prefA = new PreFile();
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets[0].Classes.Add(a);
                    prefA.Rets[1].Classes.Add(b);
                    prefiles.Add(prefA);

                    if (ac != null)
                    {
                        prefA.Rets.Add(new PreRET());
                        prefA.Rets[2].Classes.Add(ac);
                    }
                }
                else
                {
                    temp = new PreRET();
                    temp.Classes.Add(a);
                    prefB.Rets.Add(temp);
                }
            }
            else
            {
                if (prefB == null)
                {
                    temp = new PreRET();
                    temp.Classes.Add(b);
                    prefA.Rets.Add(temp);
                }
            }
        }
Example #23
0
        public override void Execute(UMLRelationship r, ActionMap map, List <PreFile> prefiles)
        {
            UMLClass a            = null;
            UMLClass b            = null;
            UMLClass ac           = null;
            int      defaultDetsA = 0;
            int      defaultDetsB = 0;
            PreFile  prefA;
            PreFile  prefB;
            PreRET   temp;

            RelationshipHelper.GetClasses(r, ref a, ref b, this.IsAlternate, ref defaultDetsA, ref defaultDetsB);


            if (r is UMLAssociation)
            {
                ac = ((UMLAssociation)r).AssociationClass;
            }

            prefA = PreFileHelper.GetPreFileWithClass(a, prefiles);
            prefB = PreFileHelper.GetPreFileWithClass(b, prefiles);

            if (prefA == null)
            {
                if (prefB == null)
                {
                    prefA = new PreFile();
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets[0].Classes.Add(a);
                    prefA.Rets[1].Classes.Add(b);
                    prefiles.Add(prefA);

                    if (ac != null)
                    {
                        prefA.Rets.Add(new PreRET());
                        prefA.Rets[2].Classes.Add(ac);
                    }
                }
                else
                {
                    temp = new PreRET();
                    temp.Classes.Add(a);
                    prefB.Rets.Add(temp);
                }
            }
            else
            {
                if (prefB == null)
                {
                    temp = new PreRET();
                    temp.Classes.Add(b);
                    prefA.Rets.Add(temp);
                }
            }
        }
 void InstallKeyMap()
 {
     ActionMap.Register(new KeyStroke(Keys.A, InputFlags.ShortCutKey), args => SelectAll());
     ActionMap.Register(new KeyStroke(Keys.X, InputFlags.ShortCutKey), args => CutSelectedText());
     ActionMap.Register(new KeyStroke(Keys.C, InputFlags.ShortCutKey), args => CopySelectedText());
     ActionMap.Register(new KeyStroke(Keys.V, InputFlags.ShortCutKey), args => PasteText());
     ActionMap.Register(new KeyStroke(Keys.Back), OnBackKey);
     ActionMap.Register(new KeyStroke(Keys.Delete), OnDeleteKey);
     ActionMap.Register(new KeyStroke(Keys.Escape), ClearSelection);
 }
Example #25
0
 public static IEnumerable <ActionMap> Decompose(this ActionMap source)
 {
     foreach (ActionMap actionMap in typeof(ActionMap).GetEnumValues())
     {
         if (actionMap != 0 && source.Contains(actionMap))
         {
             yield return(actionMap);
         }
     }
 }
Example #26
0
    void Revert()
    {
        EditorGUIUtility.keyboardControl = 0;

        ActionMap original = (ActionMap)serializedObject.targetObject;

        m_ActionMapEditCopy      = Instantiate <ActionMap>(original);
        m_ActionMapEditCopy.name = original.name;

        m_Modified = false;
    }
        public void TestMultipleActions()
        {
            var am = new ActionMap <int, int>();
            int value1 = 0, value2 = 0;

            am.OnAdd(1, x => value1 = x);
            am.OnAdd(1, x => value2 = x);
            am.Add(1, 2);
            Assert.Equal(2, value1);
            Assert.Equal(2, value2);
        }
            private void InitStablizedIdx(BlockSet stablized)
            {
                StablizedIdx = -1;

                var stablizedInOrder = new HashSet <int>();

                foreach (var idx in stablized.Indexes)
                {
                    var block    = stablized.State.Blocks[idx];
                    var position = block.Position;

                    foreach (CubeState.Axis axis in Enum.GetValues(typeof(CubeState.Axis)))
                    {
                        foreach (CubeState.Direction direction in Enum.GetValues(typeof(CubeState.Direction)))
                        {
                            var color = block.Colors[(int)axis, (int)direction];
                            if (CubeState.Color.None == color)
                            {
                                continue;
                            }

                            int actionMapIndex       = ActionMap.ColorBlockToIndex(position, axis, direction);
                            int idxInStablizingOrder = StablizingOrder.IndexOf(actionMapIndex);
                            Utils.DebugAssert(idxInStablizingOrder >= 0);

                            Utils.DebugAssert(!stablizedInOrder.Contains(idxInStablizingOrder));
                            stablizedInOrder.Add(idxInStablizingOrder);
                        }
                    }
                }

                if (stablizedInOrder.Count > 0)
                {
                    StablizedIdx = stablizedInOrder.Max();
                }

                //
                // Verify StablizedIdx
                //

                for (int i = 0; i < StablizedIdx; i++)
                {
                    Utils.DebugAssert(stablizedInOrder.Contains(i));
                }

                if (stablizedInOrder.Count > 0)
                {
                    Utils.DebugAssert(stablizedInOrder.Max() == stablizedInOrder.Count - 1);
                }
                else
                {
                    StablizedIdx = -1;
                }
            }
Example #29
0
 public ColorfulLabel(string s) : base(s)
 {
     InputMap.Put(new KeyStroke('c', false, false, false), "color");
     ActionMap.Put("color", (o, args) =>
     {
         var rng    = new Random();
         var values = Enum.GetValues(typeof(ConsoleColor));
         Foreground = (ConsoleColor?)values.GetValue(rng.Next(values.Length));
         Print(args.Graphics);
     });
 }
        public void initialize()
        {
            ActionMap map = new ObjectCreator("ActionMap").Create();

            map.bindCmd("keyboard", "1", "ConvexEditorNoneModeBtn.performClick();", "");   // Select
            map.bindCmd("keyboard", "2", "ConvexEditorMoveModeBtn.performClick();", "");   // Move
            map.bindCmd("keyboard", "3", "ConvexEditorRotateModeBtn.performClick();", ""); // Rotate
            map.bindCmd("keyboard", "4", "ConvexEditorScaleModeBtn.performClick();", "");  // Scale
            this.map = map;

            this.initSettings();
        }
        public static void initialize()
        {
            new ObjectCreator("ActionMap", "EditorMap").Create();

            ActionMap EditorMap = "EditorMap";

            EditorMap.bind("mouse", "xaxis", "editorYaw");
            EditorMap.bind("mouse", "yaxis", "editorPitch");
            EditorMap.bind("mouse", "zaxis", "mouseWheelScroll");

            EditorMap.bind("mouse", "alt zaxis", "editorWheelFadeScroll");
        }
Example #32
0
File: Toy.cs Project: smelch/BVB
        public override ActionMap GetActionMenu()
        {
            var map = new ActionMap();

            if (Abilities.Count > 0)
                map.Add(Keys.Q, () => Abilities[0].Execute());

            if (Abilities.Count > 1)
                map.Add(Keys.W, () => Abilities[1].Execute());

            if (Abilities.Count > 2)
                map.Add(Keys.E, () => Abilities[2].Execute());

            if (Abilities.Count > 3)
                map.Add(Keys.R, () => Abilities[3].Execute());

            return map;
        }
Example #33
0
        public override void Execute(UMLRelationship r, ActionMap map, List<PreFile> prefiles)
        {
            UMLClass a = null;
            UMLClass b = null;
            int defaultDetsA = 0;
            int defaultDetsB = 0;
            PreFile prefA;
            PreFile prefB;
            PreRET temp;

            RelationshipHelper.GetClasses(r, ref a, ref b, this.IsAlternate, ref defaultDetsA, ref defaultDetsB);

            prefA = PreFileHelper.GetPreFileWithClass(a, prefiles);
            prefB = PreFileHelper.GetPreFileWithClass(b, prefiles);

            if (prefA == null)
            {
                if (prefB == null)
                {
                    prefA = new PreFile();
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets[0].Classes.Add(a);
                    prefA.Rets[1].Classes.Add(b);
                    prefA.Rets[1].Parents.Add(prefA.Rets[0]);

                    prefiles.Add(prefA);
                }
                else
                {
                    temp = new PreRET();
                    temp.Classes.Add(a);
                    prefB.Rets.Add(temp);

                    foreach (PreRET ret in PreFileHelper.GetPreRETsWithClass(b, prefB))
                    {
                        ret.Parents.Add(temp);
                    }
                }
            }
            else
            {
                if (prefB == null)
                {
                    temp = new PreRET();
                    temp.Classes.Add(b);
                    prefA.Rets.Add(temp);

                    foreach (PreRET ret in PreFileHelper.GetPreRETsWithClass(a, prefA))
                    {
                        temp.Parents.Add(ret);
                    }
                }
                else
                {
                    foreach (PreRET retparent in PreFileHelper.GetPreRETsWithClass(a, prefA))
                    {
                        foreach (PreRET retchild in PreFileHelper.GetPreRETsWithClass(b, prefB))
                        {
                            retchild.Parents.Add(retparent);
                            //Merging to form the Real RET is done in the FileProcessing
                        }
                    }

                    prefA.Merge(prefB);
                    prefiles.Remove(prefB);
                }
            }
        }
Example #34
0
File: Game1.cs Project: smelch/BVB
 private void HandleInput(GameTime gameTime)
 {
     var mouse = Mouse.GetState();
     var pos = new Vector2(mouse.X, mouse.Y);
     var keyboard = Keyboard.GetState();
     var pressedKeys = keyboard.GetPressedKeys();
     if (mouse.RightButton == ButtonState.Pressed)
     {
         selectedObject.Move(pos);
     }
     else if (mouse.LeftButton == ButtonState.Pressed)
     {
         foreach (var toy in Objects)
         {
             if (toy is ISelectable)
             {
                 var delta = pos - toy.Position;
                 if (delta.X >= 0 && delta.X <= toy.Size && delta.Y >= 0 && delta.Y <= toy.Size)
                 {
                     ISelectable selected = (ISelectable)toy;
                     selected.Select();
                     selectedObject = toy;
                     map = selected.GetActionMenu();
                     break;
                 }
             }
         }
     }
     foreach (var key in pressedKeys)
     {
         map.TriggerAction(key);
     }
 }
Example #35
0
        private void Analyze(
            ISymbol symbol, 
            Compilation compilation,
            ActionMap<SymbolAnalysisContext, SymbolKind> perCompilationSymbolActions,
            Action<Diagnostic> reportDiagnostic, 
            CancellationToken cancellationToken)
        {            
            var symbolContext = new SymbolAnalysisContext(symbol, compilation, _options, reportDiagnostic, _isSupportedDiagnostic, cancellationToken);

            GlobalRoslynAnalysisContext.SymbolActions.Invoke(symbol.Kind, symbolContext);
            perCompilationSymbolActions.Invoke(symbol.Kind, symbolContext);
        }
Example #36
0
 // Check if an action map has been triggered this frame
 private static bool IsActionMapTriggered(ActionMap actionMap)
 {
     for (int i = 0; i < actionMap.keyboardKeys.Count; i++)
     {
         if (IsKeyTriggered(actionMap.keyboardKeys[i]))
             return true;
     }
     return false;
 }
        public void Analyze(string targetPath, Action<Diagnostic> reportDiagnostic, CancellationToken cancellationToken = default(CancellationToken))
        {
            // Create a Roslyn representation of the IL by constructing a MetadataReference against
            // the target path (as if we intended to reference this binary during compilation, instead
            // of analyzing it). Using this mechanism, we can scan types/members contained in the
            // binary. We cannot currently retrieve IL from method bodies.
            var reference = MetadataReference.CreateFromFile(targetPath);
            var compilation = CSharpCompilation.Create("_", references: new[] { reference });
            var target = compilation.GetAssemblyOrModuleSymbol(reference);

            // For each analysis target, we create a compilation start context, which may result
            // in symbol action registration. We need to capture and throw these registrations
            // away for each binary we inspect.
            var compilationStartAnalysisContext = new RoslynCompilationStartAnalysisContext(compilation, _options, cancellationToken);
            _perCompilationSymbolsActions = compilationStartAnalysisContext.SymbolActions;

            GlobalRoslynAnalysisContext.CompilationStartActions?.Invoke(compilationStartAnalysisContext);

            var visitor = new RoslynSymbolVisitor(symbol => Analyze(symbol, compilation, reportDiagnostic, cancellationToken));
            visitor.Visit(target);

            // Having finished analysis, we'll invoke any compilation end actions registered previously.
            // We also discard the per-compilation symbol actions we collected.
            var compilationAnalysisContext = new CompilationAnalysisContext(compilation, _options, reportDiagnostic, _isSupportedDiagnostic, cancellationToken);

            GlobalRoslynAnalysisContext.CompilationActions?.Invoke(compilationAnalysisContext);
            compilationStartAnalysisContext.CompilationEndActions?.Invoke(compilationAnalysisContext);

            _perCompilationSymbolsActions = null;
        }
Example #38
0
        /// <summary>
        /// Check if an action map has been triggered this frame.
        /// </summary>
        private static bool IsActionMapTriggered(ActionMap actionMap)
        {
            bool result = false;
            for (int i = 0; i < actionMap.keyboardKeys.Count; i++)
            {
                if (IsKeyTriggered(actionMap.keyboardKeys[i]))
                {
                    result =  true;
                }
            }
            if (currentGamePadState.IsConnected)
            {
                for (int i = 0; i < actionMap.gamePadButtons.Count; i++)
                {
                    if (IsGamePadButtonTriggered(actionMap.gamePadButtons[i]))
                    {
                        result =  true;
                    }
                }
            }

            // Handle Windows Phone gestures
            if (!result)
            {
                if (actionMap.PhoneInput.IsStartGesture)
                {
                    result = IsStartPressed();
                }
                else if (actionMap.PhoneInput.IsBackGesture)
                {
                    result = IsBackPressed();
                }
                else
                {
                    if (Gestures.Count > 0)
                    {
                        GestureSample gesture = Gestures[Gestures.Count - 1];
                        if (gesture.GestureType == actionMap.PhoneInput.Type
                            && gesture.GetDirection() == actionMap.PhoneInput.Direction)
                        {
                            InputManager.Gestures.Remove(gesture);
                            result = true;
                        }
                    }
                }
            }

            return result;
        }
Example #39
0
        public override void Execute(UMLRelationship r, ActionMap map, List<PreFile> prefiles)
        {
            UMLClass a = null;
            UMLClass b = null;
            UMLClass ac = null;
            int defaultDetsA = 0;
            int defaultDetsB = 0;
            PreFile prefA;
            PreFile prefB;

            RelationshipHelper.GetClasses(r, ref a, ref b, this.IsAlternate, ref defaultDetsA, ref defaultDetsB);


            if (r is UMLAssociation)
            {
                ac = ((UMLAssociation)r).AssociationClass; 
            }

            prefA = PreFileHelper.GetPreFileWithClass(a, prefiles);
            prefB = PreFileHelper.GetPreFileWithClass(b, prefiles);

            if (prefA == null)
            {
                if (prefB == null)
                {
                    prefA = new PreFile();
                    prefA.Rets.Add(new PreRET());
                    prefA.Rets[0].Classes.Add(a);
                    prefA.Rets[0].Classes.Add(b);

                    if (ac != null)
                    {
                        prefA.Rets[0].Classes.Add(ac);
                    }

                    prefiles.Add(prefA);
                }
                else
                {
                    foreach (PreRET ret in PreFileHelper.GetPreRETsWithClass(b, prefB))
                    {
                        ret.Classes.Add(a);
                        if (ac != null)
                        {
                            ret.Classes.Add(ac);
                        }
                    }
                }
            }
            else
            {
                if (prefB == null)
                {
                    foreach (PreRET ret in PreFileHelper.GetPreRETsWithClass(a, prefA))
                    {
                        ret.Classes.Add(b);
                        if (ac != null)
                        {
                            ret.Classes.Add(ac);
                        }
                    }
                }
                else
                {
                    foreach (PreRET reta in PreFileHelper.GetPreRETsWithClass(a, prefA))
                    {
                        foreach (PreRET retb in PreFileHelper.GetPreRETsWithClass(b, prefB))
                        {
                            reta.Merge(retb);
                            prefB.Rets.Remove(retb);

                            if (ac != null)
                            {
                                reta.Classes.Add(ac);
                            }
                        }
                    }

                    prefA.Merge(prefB);
                    prefiles.Remove(prefB);
                }
            }
        }
Example #40
0
		private bool IsActionMapPressed( ActionMap actionMap ) {
			for( int i = 0; i < actionMap.Keys.Count; i++ )
				if( IsKeyDown( actionMap.Keys[ i ] ) == true )
					return true;
			return false;
		}
Example #41
0
        //METHODS
        #region Methods
        public static ActionMap ReadFile(string filepath)
        {
            StreamReader sr = new StreamReader(filepath);
            String line;
            String[] tokens;
            ActionKey actionKey;
            ActionMap map = new ActionMap();
            Type actionType;
            String actionKeyString;
            int linecounter = 0;

            while (!sr.EndOfStream)
            {
                line = sr.ReadLine();
                linecounter++;
                tokens = line.Split('/');
                //tokens[0] = entry-type
                //tokens[1] = parameters
                actionKeyString = EncodeEntryType(tokens[0],linecounter);

                tokens = tokens[1].Split(':');

                //verify action format is valid
                switch (actionKeyString[0].ToString())
                {
                    case ActionKey.EntryType.ASSOCIATION:
                        actionKeyString += EncodeParametersAssociation(tokens, linecounter);
                        break;
                    case ActionKey.EntryType.ASSOCIATIONCLASS:
                        actionKeyString += EncodeParametersAssociationClass(tokens, linecounter);
                        break;
                    case ActionKey.EntryType.GENERALIZATION:
                        actionKeyString += EncodeParametersGeneralization(tokens, linecounter);
                        break;
                    case ActionKey.EntryType.REALIZATION:
                        actionKeyString += EncodeParametersRealization(tokens, linecounter);
                        break;
                }

                if (Regex.IsMatch(tokens[tokens.Length - 1], @"^[A-Za-z0-9]*$"))
                {
                    actionKey = new ActionKey(actionKeyString);

                    //add the value-pair if no equal action-key exists
                    if (map.GetAction(actionKey) == null)
                    {
                        //create/validate action object
                        actionType = Type.GetType(ActionKey.ACTIONNAMESPACE + tokens[tokens.Length - 1]);
                        //add the map entry
                        map.Add(actionKey, (AbstractAction)Activator.CreateInstance(actionType));
                    }
                    else
                    {
                        throw new InvalidOperationException("An equivalent ActionKey already exists in the ActionMap at line: " + linecounter);
                    }
                }
                else
                {
                    throw new ArgumentException("The action-name contains some invalid characters at line: " + linecounter);
                }
            }

            return map;
        }
Example #42
0
 /// <summary>
 /// Check if an action map has been triggered this frame
 /// </summary>
 /// <param name="aActionMap"></param>
 /// <returns></returns>
 private static bool isActionMapTriggered(ActionMap aActionMap)
 {
     for (int i = 0; i < aActionMap.mKeyboardKeys.Count; ++i)
     {
         if (isKeyTriggered(aActionMap.mKeyboardKeys[i]))
         {
             return true;
         }
     }
     if (mCurrentGamePadState.IsConnected)
     {
         for (int i = 0; i < aActionMap.mGamePadButtons.Count; ++i)
         {
             if (isGamePadButtonTriggered(aActionMap.mGamePadButtons[i]))
             {
                 return true;
             }
         }
     }
     return false;
 }
 public DefaultRelationshipAnalyzer(String actionfilepath)
 {
     this.map = ActionReader.ReadFile(actionfilepath);
 }
Example #44
0
 //METHODS
 #region Methods
 public abstract void Execute(UMLRelationship r, ActionMap map, List<PreFile> files);
Example #45
0
        public override void Execute(UMLRelationship r, ActionMap map, List<PreFile> prefiles)
        {
            UMLClass a=null;
            UMLClass b=null;
            int defaultDetsA = 0;
            int defaultDetsB = 0;
            PreFile temp, tempA, tempB;

            RelationshipHelper.GetClasses(r, ref a, ref b, this.IsAlternate, ref defaultDetsA, ref defaultDetsB);

            //1st File
            if ((tempA = PreFileHelper.GetPreFileWithClass(a, prefiles)) == null)
            {
                tempA = new PreFile();
                tempA.Rets.Add(new PreRET());
                tempA.Rets[0].Classes.Add(a);
                prefiles.Add(tempA);
            }
            tempA.DefaultDets += defaultDetsA;

            //2nd File
            if ((tempB = PreFileHelper.GetPreFileWithClass(b, prefiles)) == null)
            {
                tempB = new PreFile();
                tempB.Rets.Add(new PreRET());
                tempB.Rets[0].Classes.Add(b);                
                prefiles.Add(tempB);
            }

            tempB.DefaultDets += defaultDetsB;

            //3rd File (only if there is an Association-Class)
            if (r is UMLAssociation)
            {
                if (((UMLAssociation)r).AssociationClass != null)
                {
                    UMLClass dependencyClass = null;
                    UMLClass associationClass = ((UMLAssociation)r).AssociationClass;
                    UMLDependencyCollection dependencies = associationClass.GetDependencies();
                    
                    foreach (UMLDependency d in dependencies)
                    {
                        d.Client = Helper.GetDependencyClient<UMLClass>(d.Guid);
                        d.Supplier = Helper.GetDependencySupplier<UMLClass>(d.Guid);

                        if ((d.Client.Guid == associationClass.Guid && d.Supplier.Guid == a.Guid) ||
                            (d.Supplier.Guid == associationClass.Guid && d.Client.Guid == a.Guid))
                            dependencyClass = a;
                        else if ((d.Client.Guid == associationClass.Guid && d.Supplier.Guid == b.Guid) ||
                            (d.Supplier.Guid == associationClass.Guid && d.Client.Guid == b.Guid))
                            dependencyClass = b;
                    }
                    if (dependencyClass == null)
                    {
                        //temp = PreFileHelper.GetPreFileWithClass(a, prefiles);
                        //if (temp == null)
                        temp = new PreFile();
                        temp.Rets.Add(new PreRET());
                        temp.Rets[0].Classes.Add(((UMLAssociation)r).AssociationClass);
                        prefiles.Add(temp);
                    }
                    else if (dependencyClass == a)
                    {
                        PreRET pret = new PreRET();
                        pret.Classes.Add(associationClass);
                        tempA.Rets.Add(pret);
                    }
                    else if (dependencyClass == b)
                    {
                        PreRET pret = new PreRET();
                        pret.Classes.Add(associationClass);
                        tempB.Rets.Add(pret);
                    }
                }
            }
        }
Example #46
0
 /// <summary>
 /// Check if an action map has been triggered this frame.
 /// </summary>
 private static bool IsActionMapTriggered(ActionMap actionMap)
 {
     for (int i = 0; i < actionMap.keyboardKeys.Count; i++)
     {
         if (IsKeyTriggered(actionMap.keyboardKeys[i]))
         {
             return true;
         }
     }
     foreach (MouseButtons mButton in actionMap.mouseButtons)
     {
         if (IsMouseButtonTriggered(mButton))
             return true;
     }
     if (currentGamePadState.IsConnected)
     {
         for (int i = 0; i < actionMap.gamePadButtons.Count; i++)
         {
             if (IsGamePadButtonTriggered(actionMap.gamePadButtons[i]))
             {
                 return true;
             }
         }
     }
     return false;
 }
        /// <summary>
        /// Check if an action map has been pressed.
        /// </summary>
        private static bool IsActionMapPressed(ActionMap actionMap)
        {
            bool result = false;
            for (int i = 0; i < actionMap.keyboardKeys.Count; i++)
            {
                if (IsKeyPressed(actionMap.keyboardKeys[i]))
                {
                    result = true;
                }
            }
         

            // Handle Windows Phone gestures
            if (!result)
            {
                // TODO
                //if (actionMap.PhoneInput.IsStartGesture)
                //{
                //    result = IsStartPressed();
                //}
                //else if (actionMap.PhoneInput.IsBackGesture)
                //{
                //    result = IsBackPressed();
                //}
                // else
                {
                    if (Gestures.Count > 0)

                    {

                        GestureSample gesture = Gestures[Gestures.Count - 1];
                        if (gesture.GestureType == actionMap.PhoneInput.Type)
                        {
                            if (gesture.GetDirection() == actionMap.PhoneInput.Direction
                                && gesture.GetDirection() == actionMap.PhoneInput.Direction)
                            {
                                InputManager.Gestures.Remove(gesture);
                                result = true;
                            }
                        }
                    }
                }
            }
            return result;
        }
 /// <summary>
 /// Check if an action map has been triggered this frame.
 /// </summary>
 private static bool IsActionMapTriggered(ActionMap actionMap)
 {
     for (int i = 0; i < actionMap.keyboardKeys.Count; i++)
     {
         if (IsKeyTriggered(actionMap.keyboardKeys[i]))
         {
             return true;
         }
     }
     if (CurrentGamePadState.IsConnected)
     {
         for (int i = 0; i < actionMap.gamePadButtons.Count; i++)
         {
             if (IsGamePadButtonTriggered(actionMap.gamePadButtons[i]))
             {
                 return true;
             }
         }
     }
     return false;
 }
        /// <summary>
        /// Replaces the action current stored against the given ID with a new one.
        /// </summary>
        /// <param name="actionToReplace">The ID of the action that should be replaced.</param>
        /// <param name="newAction">The new action.</param>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="actionToReplace"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     Thrown if <paramref name="newAction"/> is <see langword="null" />.
        /// </exception>
        /// <exception cref="UnknownScheduleActionException">
        ///     Thrown if <paramref name="actionToReplace"/> is not linked to a known action.
        /// </exception>
        public void Update(
            ScheduleElementId actionToReplace,
            IScheduleAction newAction)
        {
            {
                Lokad.Enforce.Argument(() => actionToReplace);
                Lokad.Enforce.Argument(() => newAction);
                Lokad.Enforce.With<UnknownScheduleActionException>(
                    m_Actions.ContainsKey(actionToReplace),
                    Resources.Exceptions_Messages_UnknownScheduleAction);
            }

            var oldInfo = m_Actions[actionToReplace].Information;
            var info = new ScheduleActionInformation(
                actionToReplace,
                oldInfo.Name,
                oldInfo.Description);
            m_Actions[actionToReplace] = new ActionMap(info, newAction);
        }