Skip to content

Commit 01c6305

Browse files
auto test improve
1 parent af1f066 commit 01c6305

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

RemixedDungeon/src/main/assets/scripts/userServices/autoTestAi.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ local function handleWindow(hero)
4545
return true
4646
end
4747

48+
if wndClass:match('WndItem') then
49+
activeWindow:onSelect(0)
50+
activeWindow:hide()
51+
return true
52+
end
53+
4854
if wndClass:match('WndChasmJump') then
4955
if math.random() < 0.05 then
5056
activeWindow:onSelect(0)

RemixedDungeon/src/main/java/com/nyrds/pixeldungeon/windows/VHBox.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ public void remove(Gizmo g) {
6666
allMembers.remove(g);
6767
}
6868

69+
public Gizmo getByIndex(int index) {
70+
return allMembers.get(index);
71+
}
72+
6973
private void putInNextRow(Gizmo g) {
7074
HBox hBox = new HBox(maxWidth);
7175
hBox.setGap(hGap);

RemixedDungeon/src/main/java/com/watabou/noosa/ui/Button.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ protected boolean onLongClick() {
9393
return false;
9494
}
9595

96+
public void simulateClick() {
97+
onClick();
98+
}
99+
96100
@Override
97101
protected void layout() {
98102
//GLog.debug("hot area: %3.0f %3.0f %3.0f %3.0f", x, y, width, height);

RemixedDungeon/src/main/java/com/watabou/pixeldungeon/windows/WndItem.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
package com.watabou.pixeldungeon.windows;
33

4+
import com.nyrds.LuaInterface;
45
import com.nyrds.pixeldungeon.mechanics.CommonActions;
56
import com.nyrds.pixeldungeon.ml.actions.CharAction;
67
import com.nyrds.pixeldungeon.ml.actions.UseItem;
@@ -21,6 +22,7 @@
2122
public class WndItem extends Window {
2223

2324
private static final float BUTTON_WIDTH = 36;
25+
private VHBox actions;
2426

2527
public WndItem(final WndBag bag, final Item item) {
2628

@@ -49,7 +51,7 @@ public WndItem(final WndBag bag, final Item item) {
4951

5052
float y = info.getY() + info.height() + GAP;
5153

52-
VHBox actions = new VHBox(WIDTH);
54+
actions = new VHBox(WIDTH);
5355
actions.setAlign(HBox.Align.Width);
5456
actions.setGap(GAP);
5557

@@ -118,7 +120,7 @@ public WndItem(final Item item, Char actor) {
118120

119121
float y = info.getY() + info.height() + GAP;
120122

121-
VHBox actions = new VHBox(WIDTH);
123+
actions = new VHBox(WIDTH);
122124
actions.setAlign(HBox.Align.Width);
123125
actions.setGap(GAP);
124126

@@ -150,4 +152,9 @@ protected void onClick() {
150152
resize(WIDTH, (int) (actions.bottom() + GAP));
151153
}
152154

155+
@LuaInterface
156+
public void onSelect(int idx) {
157+
((RedButton)actions.getByIndex(idx)).simulateClick();
158+
}
159+
153160
}

0 commit comments

Comments
 (0)