76
76
import com .bladecoder .engine .ui .SceneScreen ;
77
77
import com .bladecoder .engine .ui .TesterBot ;
78
78
import com .bladecoder .engine .ui .TextManagerUI ;
79
+ import com .bladecoder .engine .ui .ITextManagerUI ;
79
80
import com .bladecoder .engine .ui .UI ;
80
81
import com .bladecoder .engine .ui .UI .Screens ;
81
82
import com .bladecoder .engine .util .Config ;
@@ -93,7 +94,7 @@ public class DefaultSceneScreen implements SceneScreen {
93
94
private PieMenu pie ;
94
95
private InventoryUI inventoryUI ;
95
96
private Actor dialogUI ;
96
- private TextManagerUI textManagerUI ;
97
+ private Actor textManagerUI ;
97
98
private ShapeRenderer renderer ;
98
99
99
100
private InventoryButton inventoryButton ;
@@ -154,12 +155,11 @@ public boolean tap(float x, float y, int count, int button) {
154
155
else {
155
156
getInputUnProject (unprojectTmp );
156
157
157
- if (w .inCutMode ()
158
- || (!w .inCutMode () && !TextManager .AUTO_HIDE_TEXTS && textManagerUI .isVisible ())) {
159
-
160
- if (recorder .isRecording ())
158
+ if (w .inCutMode () || (!w .inCutMode () && !TextManager .AUTO_HIDE_TEXTS && textManagerUI .isVisible ())) {
159
+
160
+ if (recorder .isRecording ())
161
161
return true ;
162
-
162
+
163
163
w .getCurrentScene ().getTextManager ().next ();
164
164
} else if (inventoryUI .isVisible ()) {
165
165
inventoryUI .hide ();
@@ -305,8 +305,7 @@ public boolean keyTyped(char character) {
305
305
306
306
@ Override
307
307
public boolean scrolled (int amount ) {
308
- if (uiEnabled && !ui .getWorld ().hasDialogOptions ()
309
- && ui .getWorld ().getInventory ().isVisible ()) {
308
+ if (uiEnabled && !ui .getWorld ().hasDialogOptions () && ui .getWorld ().getInventory ().isVisible ()) {
310
309
311
310
boolean fromDown = (inventoryUI .getInventoryPos () == InventoryPos .CENTER
312
311
|| inventoryUI .getInventoryPos () == InventoryPos .DOWN );
@@ -329,10 +328,10 @@ else if ((amount > 0 && !fromDown || amount < 0 && fromDown) && !inventoryUI.isV
329
328
private final WorldListener worldListener = new WorldListener () {
330
329
@ Override
331
330
public void text (Text t ) {
332
- if (t != null && t .type == Text .Type .UI ) {
331
+ if (t != null && t .type == Text .Type .UI ) {
333
332
showUIText (t );
334
- } else {
335
- textManagerUI .setText (t );
333
+ } else {
334
+ (( ITextManagerUI ) textManagerUI ) .setText (t );
336
335
}
337
336
}
338
337
@@ -368,44 +367,44 @@ public DefaultSceneScreen() {
368
367
public UI getUI () {
369
368
return ui ;
370
369
}
371
-
370
+
372
371
private void showUIText (Text t ) {
373
372
// Type UI texts will show at the same time that TextManagerUI texts.
374
-
375
- String style = t .style == null ?"ui-text" : t .style ;
373
+
374
+ String style = t .style == null ? "ui-text" : t .style ;
376
375
Label msg = new Label (t .str , getUI ().getSkin (), style );
377
376
378
377
msg .setWrap (true );
379
378
msg .setAlignment (Align .center , Align .center );
380
379
msg .setColor (t .color );
381
380
msg .setSize (msg .getWidth () + DPIUtils .getMarginSize () * 2 , msg .getHeight () + DPIUtils .getMarginSize () * 2 );
382
-
381
+
383
382
stage .addActor (msg );
384
383
unprojectTmp .set (t .x , t .y , 0 );
385
384
ui .getWorld ().getSceneCamera ().scene2screen (getStage ().getViewport (), unprojectTmp );
386
-
385
+
387
386
float posx , posy ;
388
-
387
+
389
388
if (t .x == TextManager .POS_CENTER ) {
390
389
posx = (getStage ().getViewport ().getScreenWidth () - msg .getWidth ()) / 2 ;
391
390
} else if (t .y == TextManager .POS_SUBTITLE ) {
392
391
posx = DPIUtils .getMarginSize ();
393
392
} else {
394
393
posx = unprojectTmp .x ;
395
394
}
396
-
395
+
397
396
if (t .y == TextManager .POS_CENTER ) {
398
397
posy = (getStage ().getViewport ().getScreenHeight () - msg .getHeight ()) / 2 ;
399
398
} else if (t .y == TextManager .POS_SUBTITLE ) {
400
399
posy = getStage ().getViewport ().getScreenHeight () - msg .getHeight () - DPIUtils .getMarginSize () * 3 ;
401
400
} else {
402
401
posy = unprojectTmp .y ;
403
402
}
404
-
403
+
405
404
msg .setPosition (posx , posy );
406
405
msg .getColor ().a = 0 ;
407
- msg .addAction (sequence (Actions .fadeIn (0.4f , Interpolation .fade ), Actions . delay ( t . time ,
408
- sequence (fadeOut (0.4f , Interpolation .fade ), Actions .removeActor ()))));
406
+ msg .addAction (sequence (Actions .fadeIn (0.4f , Interpolation .fade ),
407
+ Actions . delay ( t . time , sequence (fadeOut (0.4f , Interpolation .fade ), Actions .removeActor ()))));
409
408
}
410
409
411
410
private void updateUI () {
@@ -530,16 +529,16 @@ else if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen))
530
529
531
530
// UPDATE POINTER
532
531
if (!pie .isVisible () && actorUnderCursor != currentActor ) {
533
- currentActor = actorUnderCursor ;
534
-
532
+ currentActor = actorUnderCursor ;
533
+
535
534
if (currentActor != null ) {
536
535
if (showDesc )
537
536
pointer .setDesc (currentActor .getDesc ());
538
537
539
538
Verb leaveVerb = currentActor .getVerb (Verb .LEAVE_VERB );
540
-
539
+
541
540
TextureRegion r = null ;
542
-
541
+
543
542
if (leaveVerb != null ) {
544
543
if (leaveVerb .getIcon () != null
545
544
&& (r = getUI ().getSkin ().getAtlas ().findRegion (leaveVerb .getIcon ())) != null ) {
@@ -550,18 +549,18 @@ else if (Gdx.input.isPeripheralAvailable(Peripheral.MultitouchScreen))
550
549
}
551
550
} else {
552
551
Verb actionVerb = currentActor .getVerb (Verb .ACTION_VERB );
553
-
554
- if (actionVerb != null && actionVerb .getIcon () != null
552
+
553
+ if (actionVerb != null && actionVerb .getIcon () != null
555
554
&& (r = getUI ().getSkin ().getAtlas ().findRegion (actionVerb .getIcon ())) != null ) {
556
555
pointer .setIcon (r );
557
- } else {
556
+ } else {
558
557
pointer .setHotspotIcon ();
559
558
}
560
559
}
561
560
} else {
562
561
pointer .setDefaultIcon ();
563
562
}
564
- } else if (pie .isVisible ()) {
563
+ } else if (pie .isVisible ()) {
565
564
currentActor = actorUnderCursor ;
566
565
}
567
566
}
@@ -883,7 +882,7 @@ public void actorClick(InteractiveActor a, int button) {
883
882
// SINGLE CLICK UI
884
883
// Preference TALKTO, ACTION, PICKUP, LOOKAT
885
884
String verb = Verb .TALKTO_VERB ;
886
-
885
+
887
886
if (a .getVerb (verb ) == null )
888
887
verb = Verb .PICKUP_VERB ;
889
888
@@ -959,10 +958,17 @@ public Actor getDialogUI() {
959
958
return dialogUI ;
960
959
}
961
960
962
- public void setTextManagerUI (TextManagerUI a ) {
963
- textManagerUI .remove ();
964
- textManagerUI = a ;
965
- stage .addActor (textManagerUI );
961
+ public void setTextManagerUI (Actor a ) {
962
+ if (a instanceof ITextManagerUI ) {
963
+ textManagerUI .remove ();
964
+ textManagerUI = a ;
965
+ stage .addActor (textManagerUI );
966
+ } else {
967
+ EngineLogger .error ("ERROR setTextManagerUI: actor is not a ITextManagerUI" );
968
+
969
+ dispose ();
970
+ Gdx .app .exit ();
971
+ }
966
972
}
967
973
968
974
public void setDialogUI (Actor a ) {
0 commit comments