Skip to content

Commit 34d33a7

Browse files
committed
Fix several UI bugs: inventory button doesn't hide, dialog not working well when autoselect one option and text doesn't show when returning to a scene without init
1 parent e3d1775 commit 34d33a7

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

adventure-editor/src/main/java/com/bladecoder/engineeditor/ui/EditVerbDialog.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private void updateDesc() {
124124
.getSelectedIndex();
125125

126126
if(i == -1) {
127-
if(idStr.isEmpty())
127+
if(idStr != null && idStr.isEmpty())
128128
setInfo(DEFAULT_DESC);
129129
else
130130
setInfo(CUSTOM_VERB_DESC);

adventure-editor/src/main/resources/versions.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ buildToolsVersion=27.0.3
55
libgdxVersion=1.9.8
66
roboVMGradlePluginVersion=2.3.3
77
roboVMVersion=2.3.3
8-
version=2.1.0
8+
version=2.1.1-SNAPSHOT

blade-engine/src/com/bladecoder/engine/model/Scene.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ public void retrieveAssets() {
620620

621621
soundManager.retrieveAssets();
622622
textManager.getVoiceManager().retrieveAssets();
623+
624+
if (getWorld().getListener() != null)
625+
getWorld().getListener().text(textManager.getCurrentText());
623626
}
624627

625628
@Override

blade-engine/src/com/bladecoder/engine/model/World.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,9 @@ public void setHeight(int height) {
543543

544544
public void showInventory(boolean b) {
545545
getInventory().setVisible(b);
546+
547+
if(listener != null)
548+
listener.inventoryEnabled(b);
546549
}
547550

548551
public String getCurrentInventory() {

blade-engine/src/com/bladecoder/engine/ui/DialogUI.java

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
3131
import com.badlogic.gdx.scenes.scene2d.utils.Drawable;
3232
import com.badlogic.gdx.utils.Align;
33+
import com.badlogic.gdx.utils.Timer;
34+
import com.badlogic.gdx.utils.Timer.Task;
3335
import com.bladecoder.engine.i18n.I18N;
3436
import com.bladecoder.engine.util.DPIUtils;
3537

@@ -46,12 +48,12 @@ public class DialogUI extends ScrollPane {
4648
private Button down;
4749

4850
private List<String> choices;
49-
51+
5052
private final UI ui;
5153

5254
public DialogUI(UI ui) {
5355
super(new Table(ui.getSkin()), ui.getSkin());
54-
56+
5557
this.ui = ui;
5658

5759
setFadeScrollBars(true);
@@ -110,13 +112,13 @@ public void changed(ChangeEvent event, Actor actor) {
110112
}
111113
});
112114
}
113-
115+
114116
@Override
115-
public void setVisible (boolean visible) {
117+
public void setVisible(boolean visible) {
116118
super.setVisible(visible);
117-
118-
if(visible) {
119-
if(getParent() != null)
119+
120+
if (visible) {
121+
if (getParent() != null)
120122
show();
121123
} else {
122124
up.remove();
@@ -130,10 +132,20 @@ private void show() {
130132
if (choices.size() == 0)
131133
return;
132134

133-
else if (style.autoselect && choices.size() == 1) {
135+
else if (style.autoselect && choices.size() == 1) {
134136
// If only has one option, autoselect it
135-
select(0);
136-
return;
137+
138+
// To work properly, delay the selection one frame to avoid select it before
139+
// 'talkto' finished.
140+
Timer.post(new Task() {
141+
142+
@Override
143+
public void run() {
144+
select(0);
145+
146+
return;
147+
}
148+
});
137149
}
138150

139151
panel.clear();
@@ -195,7 +207,7 @@ static public class DialogUIStyle {
195207
public Drawable background;
196208

197209
public TextButtonStyle textButtonStyle;
198-
210+
199211
// If only one option is visible, auto select it.
200212
public boolean autoselect = true;
201213

blade-engine/src/com/bladecoder/engine/ui/defaults/DefaultSceneScreen.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ public void cutMode(boolean value) {
348348

349349
@Override
350350
public void inventoryEnabled(boolean value) {
351+
inventoryUI.hide();
351352
inventoryButton.setVisible(value);
352353
}
353354

@@ -1000,8 +1001,6 @@ public void show() {
10001001
ui.getWorld().setListener(worldListener);
10011002
ui.getWorld().resume();
10021003

1003-
textManagerUI.setText(ui.getWorld().getCurrentScene().getTextManager().getCurrentText());
1004-
10051004
updateUI();
10061005
}
10071006

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=2.1.0
1+
version=2.1.1-SNAPSHOT
22
libgdxVersion=1.9.8
33
roboVMVersion=2.3.3
44
roboVMGradlePluginVersion=2.3.3

0 commit comments

Comments
 (0)