Beispiel #1
0
        public static string KeyCodeToString(KeyCode key)
        {
            var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;

            key = NormalizeKeyCode(key);
            return((int)key >= MinGamepadKey ?
                   XboxPrefix + JoystickButtonToXboxButton(InputTranslator.ConvertKeyCodeToButton(key, config)) :
                   key.ToString());
        }
Beispiel #2
0
        public Texture2D KeyTexture(KeyCode key)
        {
            if (_loadedTextures == null)
            {
                FillTextureLibrary();
            }
            var keyName = ModInputLibrary.KeyCodeToString(key);

            if (_loadedTextures.ContainsKey(keyName))
            {
                return(_loadedTextures[keyName]);
            }
            var config  = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;
            var toStore = (int)key >= ModInputLibrary.MinGamepadKey ?
                          ButtonPromptLibrary.SharedInstance.GetButtonTexture(InputTranslator.ConvertKeyCodeToButton(key, config)) :
                          ButtonPromptLibrary.SharedInstance.GetButtonTexture(key);

            _loadedTextures.Add(keyName, toStore);
            return(toStore);
        }
Beispiel #3
0
        internal void FillTextureLibrary()
        {
            _loadedTextures = new Dictionary <string, Texture2D>();
            var config = OWInput.GetActivePadConfig() ?? InputUtil.GamePadConfig_Xbox;

            for (var code = ModInputLibrary.MinUsefulKey; code < ModInputLibrary.MaxUsefulKey; code++)
            {
                var key = (KeyCode)code;
                if (!Enum.IsDefined(typeof(KeyCode), key))
                {
                    continue;
                }
                var keyName = ModInputLibrary.KeyCodeToString(key);
                if (_loadedTextures.ContainsKey(keyName))
                {
                    continue;
                }
                var button  = InputTranslator.ConvertKeyCodeToButton(key, config);
                var toStore = (int)key >= ModInputLibrary.MinGamepadKey ?
                              ButtonPromptLibrary.SharedInstance.GetButtonTexture(button) :
                              ButtonPromptLibrary.SharedInstance.GetButtonTexture(key);
                _loadedTextures.Add(keyName, toStore);
            }
        }