Skip to content

Commit 0088dcd

Browse files
committed
displace bubble with text
1 parent 0f6e520 commit 0088dcd

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public TextManagerUI(SceneScreen sceneScreen) {
5656
this.sceneScreen = sceneScreen;
5757
setTouchable(Touchable.disabled);
5858
style = sceneScreen.getUI().getSkin().get(TextManagerUIStyle.class);
59+
style.font.setMarkupEnabled(true);
5960
setVisible(false);
6061
}
6162

@@ -113,7 +114,6 @@ else if (posy == TextManager.POS_SUBTITLE)
113114

114115
setSize(b.width + PADDING * 2, b.height + PADDING * 2);
115116

116-
style.font.setMarkupEnabled(true);
117117
style.font.setColor(currentSubtitle.color);
118118

119119
// check if the text exits the screen
@@ -137,7 +137,12 @@ public void draw(Batch batch, float alpha) {
137137
if (subtitle.type == Text.Type.TALK) {
138138
if (style.talkBubble != null) {
139139
float scale = DPIUtils.getTouchMinSize() / 4 / style.talkBubble.getMinHeight();
140-
float bubbleX = getX() + (getWidth() - style.talkBubble.getMinWidth() * scale)/ 2;
140+
// float bubbleX = getX() + (getWidth() - style.talkBubble.getMinWidth() * scale)/ 2;
141+
unprojectTmp.set(subtitle.x, subtitle.y, 0);
142+
World.getInstance().getSceneCamera().scene2screen(sceneScreen.getViewport(), unprojectTmp);
143+
144+
float bubbleX = unprojectTmp.x - style.talkBubble.getMinWidth() * scale / 2;
145+
141146
float bubbleY = getY() - style.talkBubble.getMinHeight() * scale + 2;
142147

143148
// style.talkBubble.draw(batch, bubbleX, bubbleY, style.talkBubble.getMinWidth() * scale,
@@ -161,9 +166,9 @@ public void draw(Batch batch, float alpha) {
161166
getWidth() - PADDING * 2, HAlignment.CENTER);
162167
}
163168

164-
public void resize(int width, int height) {
165-
maxRectangleWidth = width / 1.7f;
166-
maxTalkWidth = width / 3;
169+
public void resize(int width, int height) {
170+
maxRectangleWidth = Math.min(width - DPIUtils.getMarginSize() * 2, style.font.getSpaceWidth() * 80);
171+
maxTalkWidth = Math.min(width - DPIUtils.getMarginSize() * 2, style.font.getSpaceWidth() * 35);
167172
}
168173

169174
/** The style for the TextManagerUI */

0 commit comments

Comments
 (0)