コード例 #1
0
        private static void ButtonsChanged(object sender, StardewModdingAPI.Events.ButtonsChangedEventArgs e)
        {
            if (Context.IsWorldReady == false)
            {
                return;                                                                                                                                                                               //do nothing
            }
            bool full    = ModEntry.Config.KeyBindings.FullTransparency.JustPressed();                                                                                                                //if a "full transparency" keybind was just pressed
            bool disable = ModEntry.Config.KeyBindings.DisableTransparency.JustPressed();                                                                                                             //if a "disable transparency" keybind was just pressed

            if (full && disable)                                                                                                                                                                      //if both keybinds were pressed just pressed in the same tick (e.g. due to partially or fully overlapping bindings)
            {
                if (ModEntry.Config.KeyBindings.DisableTransparency.GetKeybindCurrentlyDown().Buttons.Length > ModEntry.Config.KeyBindings.FullTransparency.GetKeybindCurrentlyDown().Buttons.Length) //if the "disable" keybind uses more buttons than the "full" keybind
                {
                    ToggleDisableTransparency();
                }
                else //if the "disable" keybind uses fewer/equal buttons
                {
                    ToggleFullTransparency();
                }
            }
            else if (full) //if only "full" was pressed this tick
            {
                ToggleFullTransparency();
            }
            else if (disable) //if only "disable" was pressed this tick
            {
                ToggleDisableTransparency();
            }
        }
コード例 #2
0
 private void Input_ButtonsChanged(object sender, StardewModdingAPI.Events.ButtonsChangedEventArgs e)
 {
     if (Config.EnableMod && Config.ImportKey.JustPressed())
     {
         Monitor.Log("importing map");
         DoImport();
     }
 }
コード例 #3
0
 private void Input_ButtonsChanged(object sender, StardewModdingAPI.Events.ButtonsChangedEventArgs e)
 {
     if (!Config.EnableMod || animationDict == null)
     {
         return;
     }
     foreach (var kvp in animationDict)
     {
         if (kvp.Value.keyTrigger != null && KeybindList.TryParse(kvp.Value.keyTrigger, out KeybindList keybind, out string[] errors) && keybind.JustPressed())
         {
             PlayAnimation(kvp.Key, kvp.Value);
         }
     }
 }
コード例 #4
0
 private void Input_ButtonsChanged(object sender, StardewModdingAPI.Events.ButtonsChangedEventArgs e)
 {
     if (Context.IsPlayerFree && Config.CreateDeckButton.JustPressed())
     {
         Monitor.Log("Creating new deck");
         Object deck = new Object(Vector2.Zero, 0);
         deck.modData[deckKey] = new CardDeck().GetDeckString();
         Game1.player.addItemToInventoryBool(deck, true);
     }
     else if (Context.IsPlayerFree && Config.ShuffleDeckButton.JustPressed() && Game1.player.CurrentItem is Object && (Game1.player.CurrentItem as Object).modData.TryGetValue(deckKey, out string deckString))
     {
         Monitor.Log("Shuffling deck");
         CardDeck deck = new CardDeck(deckString);
         deck.ShuffleCards();
         Game1.player.CurrentItem.modData[deckKey] = deck.GetDeckString();
     }
 }