com.megacrit.cardcrawl.helpers.input.InputHelper Java Examples

The following examples show how to use com.megacrit.cardcrawl.helpers.input.InputHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsoleTargeting.java    From jorbs-spire-mod with MIT License 6 votes vote down vote up
public void renderTargetingUi(SpriteBatch sb)
{
    float x = InputHelper.mX;
    float y = InputHelper.mY;
    this.controlPoint = new Vector2(AbstractDungeon.player.animX - (x - AbstractDungeon.player.animX) / 4.0F, AbstractDungeon.player.animY + (y - AbstractDungeon.player.animY - 40.0F * Settings.scale) / 2.0F);
    if (this.hoveredCreature == null) {
        this.arrowScale = Settings.scale;
        this.arrowScaleTimer = 0.0F;
        sb.setColor(new Color(1.0F, 1.0F, 1.0F, 1.0F));
    } else {
        this.arrowScaleTimer += com.badlogic.gdx.Gdx.graphics.getDeltaTime();
        if (this.arrowScaleTimer > 1.0F) {
            this.arrowScaleTimer = 1.0F;
        }

        this.arrowScale = com.badlogic.gdx.math.Interpolation.elasticOut.apply(Settings.scale, Settings.scale * 1.2F, this.arrowScaleTimer);
        sb.setColor(new Color(1.0F, 0.2F, 0.3F, 1.0F));
    }
    Vector2 tmp = new Vector2(this.controlPoint.x - x, this.controlPoint.y - y);
    tmp.nor();

    drawCurvedLine(sb, new Vector2(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY - 40.0F * Settings.scale), new Vector2(x, y), this.controlPoint);

    sb.draw(ImageMaster.TARGET_UI_ARROW, x - 128.0F, y - 128.0F, 128.0F, 128.0F, 256.0F, 256.0F, this.arrowScale, this.arrowScale, tmp.angle() + 90.0F, 0, 0, 256, 256, false, false);

}
 
Example #2
Source File: HitboxRightClick.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(Hitbox __instance)
{
    if (rightClicked.get(__instance)) {
        rightClicked.set(__instance, false);
    } else {
        if (rightClickStarted.get(__instance) && InputHelper.justReleasedClickRight) {
            if (__instance.hovered) {
                rightClicked.set(__instance, true);
            }
            rightClickStarted.set(__instance, false);
        }

        if (__instance.hovered && InputHelper.justClickedRight) {
            rightClickStarted.set(__instance, true);
        }
    }
}
 
Example #3
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(AbstractCard __instance) {
    if (AbstractDungeon.screen == AbstractDungeon.CurrentScreen.GRID && AbstractDungeon.gridSelectScreen.forUpgrade) {
        if (__instance.hb.hovered && InputHelper.justClickedLeft) {
            if (__instance.timesUpgraded < 0) {
                BranchSelectFields.isBranchUpgrading.set(AbstractDungeon.gridSelectScreen, true);
            } else {
                BranchSelectFields.isBranchUpgrading.set(AbstractDungeon.gridSelectScreen, false);
            }

            if (__instance instanceof BranchingUpgradesCard) {
                __instance.beginGlowing();
                cardList.forEach(c -> {
                    if (c != __instance) c.stopGlowing();
                });
            }

            BranchSelectFields.waitingForBranchUpgradeSelection.set(AbstractDungeon.gridSelectScreen, false);
        }
    }
}
 
Example #4
Source File: BranchingUpgradesPatch.java    From StSLib with MIT License 6 votes vote down vote up
public static void Postfix(SingleCardViewPopup __instance, AbstractCard ___card) {
    if (SingleCardViewPopup.isViewingUpgrade) {
        BranchUpgradeButton.isViewingBranchUpgrade.set(__instance, false);
    }

    if (___card instanceof BranchingUpgradesCard) {
        Hitbox branchUpgradeHb = BranchUpgradeButton.branchUpgradeHb.get(__instance);

        branchUpgradeHb.update();
        if (branchUpgradeHb.hovered && InputHelper.justClickedLeft) {
            branchUpgradeHb.clickStarted = true;
        }

        if (branchUpgradeHb.clicked) {
            branchUpgradeHb.clicked = false;
            SingleCardViewPopup.isViewingUpgrade = false;
            BranchUpgradeButton.isViewingBranchUpgrade.set(__instance, !BranchUpgradeButton.isViewingBranchUpgrade.get(__instance));
        }
    }
}
 
Example #5
Source File: ModsScreen.java    From ModTheSpire with MIT License 6 votes vote down vote up
private void updateScrolling()
{
    if (hitboxes.size() > 16) {
        int y = InputHelper.mY;
        if (!grabbedScreen) {
            if (InputHelper.scrolledDown) {
                targetY += Settings.SCROLL_SPEED;
            } else if (InputHelper.scrolledUp) {
                targetY -= Settings.SCROLL_SPEED;
            }
            if (InputHelper.justClickedLeft) {
                grabbedScreen = true;
                grabStartY = y - targetY;
            }
        } else if (InputHelper.isMouseDown) {
            targetY = y - grabStartY;
        } else {
            grabbedScreen = false;
        }
    }
    scrollY = MathHelper.scrollSnapLerpSpeed(scrollY, targetY);
    resetScrolling();
}
 
Example #6
Source File: FixJustReleasedRightClick.java    From StSLib with MIT License 4 votes vote down vote up
public static void Postfix()
{
    InputHelper.justReleasedClickRight = false;
}