public Keybinding(Keybindings name, Category category, Keys key) { Name = name; CategoryType = category; Key = key; IsVisible = false; }
private void Start() { ModLoader.MakeModule(this); key = Keybindings.AddKeybinding("Mod Toggle", new Key(KeyCode.LeftControl, KeyCode.M)); }
private int[][] blockIndices; // Basically same as with tabIndices private void Start() { pipette = Keybindings.Get("Pipette"); openSettings = Keybindings.Get("Open Block Settings"); nextTab = Keybindings.Get("Next Tab"); previousTab = Keybindings.Get("Previous Tab"); increaseTime = Keybindings.Get("Increase time scale"); decreaseTime = Keybindings.Get("Decrease time scale"); timeTo100 = Keybindings.Get("Set time scale to 100%"); timeTo0 = Keybindings.Get("Set time scale to 0%"); blockKeys = new Key[9]; for (int i = 0; i < 9; i++) { blockKeys[i] = Keybindings.Get("Block " + (i + 1)); } tabKeys = new Key[7]; for (int i = 0; i < 7; i++) { tabKeys[i] = Keybindings.Get("Tab " + (i + 1)); } OnSceneLoaded(default(Scene), default(LoadSceneMode)); SceneManager.sceneLoaded += OnSceneLoaded; }
private void Start() { ModLoader.MakeModule(this); key = Keybindings.AddKeybinding("Keymaper", new Key(KeyCode.LeftControl, KeyCode.J)); }
public Form1( IAxisFactory axisFactory, IMazeViewDataFactory mazeViewDataFactory, MazeNodeDataBuilder mazeNodeDataBuilder, IVisualizer visualizer, UnitMover unitMover, Maze maze, Keybindings keybindings) { _maze = maze; _unitMover = unitMover; _visualizer = visualizer; _mazeNodeDataBuilder = mazeNodeDataBuilder; _keybindings = keybindings; InitializeComponent(); InitializeMaze(axisFactory, mazeViewDataFactory); InitializeKeybindings(axisFactory); DoubleBuffered = true; fAnimator = new Timer() { Interval = 500, }; fAnimator.Tick += FAnimator_Tick1; fAnimator.Start(); }
void Start() { waitingForKey = false; keys = InputManager.instance.keybindings; evt = EventSystem.current; SetStartKeys(); }
void Start() { Keybindings.InitializePlayerAction(PlayerAction.Up, KeyCode.W); Keybindings.InitializePlayerAction(PlayerAction.Left, KeyCode.A); Keybindings.InitializePlayerAction(PlayerAction.Right, KeyCode.D); Keybindings.InitializePlayerAction(PlayerAction.Down, KeyCode.S); Keybindings.InitializePlayerAction(PlayerAction.Fire, KeyCode.Space); }
/// <summary> /// Mouse Input Trigger /// </summary> /// <param name="key">Key clicked</param> /// <param name="pos">Mouse Position at moment of click</param> protected virtual void MouseInput(Keybindings key, Vector2 pos) { if (MouseUsers != null) { MouseEvent args = new MouseEvent(key, pos); MouseUsers(this, args); } }
/// <summary> /// Movement key release trigger /// </summary> /// <param name="key">Key released</param> protected virtual void MovementRelease(Keybindings key) { if (Movement != null) { InputEvent args = new InputEvent(key); Movement(this, args); } }
/// <summary> /// Escape Key Input Trigger /// </summary> /// <param name="key">Key Pressed</param> protected virtual void EscapeInput(Keybindings key) { if (Esc != null) { InputEvent args = new InputEvent(key); Esc(this, args); SingleInputTriggered(); } }
protected virtual void CheatInput(Keybindings key) { if (Cheats != null) { InputEvent args = new InputEvent(key); Cheats(this, args); SingleInputTriggered(); } }
/// <summary> /// Use Key Input Trigger /// </summary> /// <param name="key">Key Pressed</param> protected virtual void UseInput(Keybindings key) { if (Use != null) { InputEvent args = new InputEvent(key); Use(this, args); SingleInputTriggered(); } }
private void Start() { ModLoader.MakeModule(this); HierarchyPanel = gameObject.AddComponent <HierarchyPanel>(); InspectorPanel = gameObject.AddComponent <InspectorPanel>(); key = Keybindings.AddKeybinding("Object Explorer", new Key(KeyCode.LeftControl, KeyCode.O)); }
/// <summary> /// Discards changes to temp_keybindings. Sets temp_keybindings to match keybindings. /// </summary> public void DiscardKeybinds() { if (temp_keybindings == null) { temp_keybindings = new Keybindings(); } else { temp_keybindings = keybindings.Copy(); } }
public static T Get <T>(Keybindings keybinding) where T : IKeybinding { foreach (var _keybinding in _keybindings) { if (_keybinding.Name == keybinding) { return((T)_keybinding); } } return(default);
public override void OnLoad() { UnityEngine.Object.DontDestroyOnLoad(EnhancedCamera.Instance); Keybindings.AddKeybinding("Forward", new Key(KeyCode.None, KeyCode.W)); Keybindings.AddKeybinding("Backward", new Key(KeyCode.None, KeyCode.S)); Keybindings.AddKeybinding("Left", new Key(KeyCode.None, KeyCode.A)); Keybindings.AddKeybinding("Right", new Key(KeyCode.None, KeyCode.D)); Keybindings.AddKeybinding("Up", new Key(KeyCode.None, KeyCode.Q)); Keybindings.AddKeybinding("Down", new Key(KeyCode.None, KeyCode.E)); Keybindings.AddKeybinding("Menu", new Key(KeyCode.LeftAlt, KeyCode.C)); }
private void OnApplicationQuit() { foreach (var mod in loadedMods) { mod.Deactivate(); Configuration.SetBool("modStatus:" + mod.Mod.Name, mod.IsEnabled); } Keybindings.SaveToConfig(); Configuration.Save(); }
/// <summary> /// Copies the keybindings from one instance to another /// </summary> /// <returns></returns> public Keybindings Copy() { Keybindings copy = new Keybindings(); for (int i = 0; i < 9; i++) { copy.keys[i, 0] = this.keys[i, 0]; copy.keys[i, 1] = this.keys[i, 1]; } return(copy); }
public EndScreen(Texture2D winTexture, Texture2D loseTexture, float scale, float fadeseconds, Keybindings keybindings) { Instance = this; _win = new Sprite(winTexture); _win.Scale = scale; _lose = new Sprite(loseTexture); _lose.Scale = scale; _alpha = 0; _winning = false; _alphapersecond = 255F / fadeseconds; _fadingIn = false; _keybinds = keybindings; }
public void CopyFrom(MouseOrbit o) { target = o.target; distance = o.distance; xSpeed = o.xSpeed; ySpeed = o.ySpeed; yMinLimit = o.yMinLimit; yMaxLimit = o.yMaxLimit; x = o.x; y = o.y; smooth = o.smooth; wasdPosOffset = o.wasdPosOffset; wasdSpeed = o.wasdSpeed; zoomSmooth = o.zoomSmooth; introDuration = o.introDuration; introXamount = o.introXamount; introYamount = o.introYamount; filmCamSmooth = o.filmCamSmooth; panSpeed = o.panSpeed; machineTarget = o.machineTarget; focusObject = o.focusObject; focusLerpSmooth = o.focusLerpSmooth; dofTarget = o.dofTarget; minZoom = o.minZoom; maxZoom = o.maxZoom; mouseSensitivityScaler = o.mouseSensitivityScaler; scrollSensitivityScaler = o.scrollSensitivityScaler; fixedCam = o.fixedCam; fixedCamObj = o.fixedCamObj; fixedCamLookAt = o.fixedCamLookAt; fixedCamLerpPosSpeed = o.fixedCamLerpPosSpeed; fixedCamLerpRotSpeed = o.fixedCamLerpRotSpeed; lerpedUpVector = o.lerpedUpVector; yPosClamp = o.yPosClamp; hud3Dcam = o.hud3Dcam; forward = Keybindings.Get("Forward"); backward = Keybindings.Get("Backward"); left = Keybindings.Get("Left"); right = Keybindings.Get("Right"); up = Keybindings.Get("Up"); down = Keybindings.Get("Down"); menu = Keybindings.Get("Menu"); wasdSpeed = Configuration.GetFloat("wasdSpeed", wasdSpeed); scrollSensitivityScaler = Configuration.GetFloat("scrollSpeed", scrollSensitivityScaler); fov = Configuration.GetFloat("fov", Camera.main.fieldOfView); focusLerpSmooth = Configuration.GetFloat("focusLerpSmooth", focusLerpSmooth); }
/// <summary> /// Sets keybindings to match temp_keybindings, and saves to file as well. /// </summary> public void ApplyKeybinds() { if (temp_keybindings == null) { temp_keybindings = new Keybindings(); } keybindings = temp_keybindings.Copy(); //Debug.Log("Saving to location: \"" + Application.persistentDataPath + "\\Keybindings.txt\""); Stream stream = new FileStream(Application.persistentDataPath + "\\Keybindings.txt", FileMode.Create, FileAccess.Write); formatter.Serialize(stream, keybindings); stream.Close(); }
private void DoWindow(int id) { var keybindings = Keybindings.GetAllKeybindings(); scrollPos = GUILayout.BeginScrollView(scrollPos); foreach (var modPair in keybindings) { if (DoSectionTitle(modPair.Key)) { foreach (var bindingPair in keybindings[modPair.Key]) { DoKeybinding(modPair.Key, bindingPair.Key, bindingPair.Value); } } } GUILayout.EndScrollView(); if (Event.current.type == EventType.Repaint) { if (GUI.tooltip == "") { currentKeyToMap = null; } else { var parts = GUI.tooltip.Split(':'); if (parts.Length != 3) { currentKeyToMap = null; } else { currentKeyToMap = keybindings[parts[0]][parts[1]]; if (parts[2] == "modifier") { currentlyModifier = true; } else { currentlyModifier = false; } } } } GUI.DragWindow(new Rect(0, 0, windowRect.width, GUI.skin.window.padding.top)); }
private void OnEnable() { ModLoader.MakeModule(this); Application.logMessageReceived += HandleLog; entries = new List <LogEntry>(); windowRect = new Rect(50f, 50f, Elements.Settings.ConsoleSize.x, Elements.Settings.ConsoleSize.y); initMessageFiltering(); registerClear(); key = Keybindings.AddKeybinding("Console", new Key(KeyCode.LeftControl, KeyCode.K)); }
/// <summary> /// Loads keybindings from file if file exist, else loads default keybindsings. /// </summary> public void LoadKeybinds() { if (File.Exists(Application.persistentDataPath + "\\Keybindings.txt")) { //Debug.Log("Loading keybinds from location: \"" + Application.persistentDataPath + "\\Keybindings.txt\""); Stream stream = new FileStream(Application.persistentDataPath + "\\Keybindings.txt", FileMode.Open, FileAccess.Read); keybindings = (Keybindings)formatter.Deserialize(stream); temp_keybindings = keybindings.Copy(); } else { //Debug.Log("Loading default keybinds"); keybindings = new Keybindings(); temp_keybindings = keybindings.Copy(); } }
private void Start() { DontDestroyOnLoad(this); loadedMods = new List <InternalMod>(); loadedMods.Add(new InternalMod(new LoaderMod(), Assembly.GetExecutingAssembly())); Commands.Initialize(); // Create the console before loading the config so it can display // possible errors. var console = Tools.Console.Instance; Configuration.Load(); Keybindings.LoadFromConfig(); Game.Initialize(); SettingsMenu.Initialize(); OptionsMenu.Initialize(); MachineData.Initialize(); Tools.ModToggle.Initialize(); Tools.Keymapper.Initialize(); #if DEV_BUILD Tools.ObjectExplorer.Initialize(); if (Environment.CommandLine.Contains("-enable-debug-server")) { Tools.DebugServer.Initialize(); Tools.DebugServer.Instance.StartDebugServer(5000); } #endif // Enable the console interface since it can now ask the configuration // for the correct keys to use. console.EnableInterface(); var blockLoaderInfo = new TheGuysYouDespise.BlockLoaderInfo(); blockLoaderInfo.LoadBlockLoader(); LoadMods(); RegisterModManagementCommands(); InitializeMods(); UpdateChecker.Initialize(); }
/// <summary> /// Load or create all keybinds /// </summary> private void Awake() { if (!Directory.Exists(CFG_FOLDER)) { Debug.Log("No config folder, creating..."); Directory.CreateDirectory(CFG_FOLDER); } if (File.Exists(CFG_FOLDER + KEYS_CFG)) { keybinds = JsonConvert.DeserializeObject <Keybindings>(File.ReadAllText(CFG_FOLDER + KEYS_CFG)); } else { Debug.Log("No keys file, creating..."); LoadDefaultKeybinds(); SaveKeybindsToFile(); } }
/// <summary> /// Loads all default keybinds into the Dictionary /// </summary> public void LoadDefaultKeybinds() { keybinds = new Keybindings(); // Player 1 keybinds.player1.Add(KeyCode.A, InputOption.Forward); keybinds.player1.Add(KeyCode.D, InputOption.Backward); keybinds.player1.Add(KeyCode.W, InputOption.Up); keybinds.player1.Add(KeyCode.S, InputOption.Down); keybinds.player1.Add(KeyCode.R, InputOption.LPunch); keybinds.player1.Add(KeyCode.T, InputOption.RPunch); // Player 2 InputOption. keybinds.player2.Add(KeyCode.J, InputOption.Forward); keybinds.player2.Add(KeyCode.L, InputOption.Backward); keybinds.player2.Add(KeyCode.I, InputOption.Up); keybinds.player2.Add(KeyCode.K, InputOption.Down); keybinds.player2.Add(KeyCode.Keypad4, InputOption.LPunch); keybinds.player2.Add(KeyCode.Keypad5, InputOption.RPunch); }
public void Start() { DontDestroyOnLoad(this); button = new SettingsButton() { Text = "Keys", Value = false, OnToggle = OnInterfaceToggle }; button.Create(); windowRect.x = Configuration.GetFloat("main-x", 1100f); windowRect.y = Configuration.GetFloat("main-y", 309); windowRect.width = 400; windowRect.height = 500; editInterface.LoadWindowPosition(); toggleKey = Keybindings.AddKeybinding("Key Manager", new Key(KeyCode.RightControl, KeyCode.M)); }
private void UpdateKeyValues(Keybindings profile) { if (keybindingTexts.Count <= 0) { for (int i = 0; i < profile.keybinding.Count; i++)// Create all buttons and text fields { GameObject newButton = Instantiate(button, transform.parent.GetChild(transform.parent.childCount - 1)).gameObject; Text buttonText = newButton.GetComponentInChildren <Text>(); buttonText.text = profile.keybinding[i].keyValue.ToString(); newButton.GetComponentInChildren <Button>().onClick.AddListener(delegate { PressButton(newButton.gameObject); }); keybindingTexts.Add(buttonText); Instantiate(keybindingText, transform).GetComponentInChildren <Text>().text = profile.keybinding[i].actionName.ToString(); } } else { for (int i = 0; i < keybindingTexts.Count; i++)// Updates all the texts { keybindingTexts[i].text = profile.keybinding[i].keyValue.ToString(); } } }
private void Update() { if (FogOfWar.Instance.FoWTexture == null) { return; } if (Keybindings.UIExpandMinimap) { minimapExpanded = !minimapExpanded; if (minimapExpanded) { Keybindings.DeactivateInputMode(Keybindings.InputMode.Player); Keybindings.ActivateInputMode(Keybindings.InputMode.Minimap); DOTween.To(() => minimapExpandedAmount, x => minimapExpandedAmount = x, 1f, minimapExpandDuration).OnUpdate(OnTweenUpdate).SetEase(Ease.InOutSine); } else { Keybindings.DeactivateInputMode(Keybindings.InputMode.Minimap); Keybindings.ActivateInputMode(Keybindings.InputMode.Player); DOTween.To(() => minimapExpandedAmount, x => minimapExpandedAmount = x, 0f, minimapExpandDuration).OnUpdate(OnTweenUpdate).SetEase(Ease.InOutSine); } } if (minimapObject.texture != FogOfWar.Instance.FoWTexture) { minimapObject.texture = FogOfWar.Instance.FoWTexture; } Rect uvRect = minimapObject.uvRect; uvRect.width = minimapObject.rectTransform.rect.width / minimapObject.texture.width; uvRect.height = minimapObject.rectTransform.rect.height / minimapObject.texture.height; Vector3Int playerTilePosition = FogOfWar.Instance.WorldToTile(Main.Instance.player.transform.position); uvRect.x = playerTilePosition.x / (float)minimapObject.texture.width - uvRect.width / 2f; uvRect.y = playerTilePosition.y / (float)minimapObject.texture.height - uvRect.height / 2f; minimapObject.uvRect = uvRect; }