From f96b27aa9b3c6e77d06a5f696901b113e3c9fb8a Mon Sep 17 00:00:00 2001 From: Leo Gassman Date: Sun, 27 Dec 2020 18:37:25 -0300 Subject: [PATCH] fix text position --- .../uqbar/project/wollok/game/VisualComponent.xtend | 12 ++---------- .../uqbar/project/wollok/game/gameboard/Window.xtend | 4 ++++ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/VisualComponent.xtend b/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/VisualComponent.xtend index 998b899759..01baae07dc 100644 --- a/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/VisualComponent.xtend +++ b/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/VisualComponent.xtend @@ -21,6 +21,7 @@ class VisualComponent { List balloonMessages = newArrayList boolean showAttributes = false + boolean hasText = false WollokObject wObject @@ -43,15 +44,6 @@ class VisualComponent { wObject.call(TEXT_CONVENTION) hasText = true }catch(WollokProgramExceptionWrapper e) { - println("ERROR TRATANDO DE ENCONTRAR EL METODO TEXT") - e.printStackTrace() - throw e; - //TODO check only for method dont understand - } - catch(RuntimeException e) { - println("ERROR TRATANDO DE ENCONTRAR EL METODO TEXT 2") - e.printStackTrace() - throw e; } } @@ -92,7 +84,7 @@ class VisualComponent { } def drawText(Window window) { - if(hasText) window.write(wObject.call(TEXT_CONVENTION).wollokToJava(String) as String, Color.BLACK, getPosition().x, getPosition().y) + if(hasText) window.writeText(wObject.call(TEXT_CONVENTION).wollokToJava(String) as String, getPosition(), Color.BLACK) } def drawAttributesIfNecesary(Window window) { diff --git a/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/gameboard/Window.xtend b/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/gameboard/Window.xtend index 2f902e9eac..870189b5d0 100644 --- a/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/gameboard/Window.xtend +++ b/org.uqbar.project.wollok.game/src/org/uqbar/project/wollok/game/gameboard/Window.xtend @@ -61,6 +61,10 @@ class Window { def doDraw(Texture texture, Position it, ImageSize size) { batch.draw(texture, xinPixels, yinPixels, size.width(texture.width), size.height(texture.height)) } + + def writeText(String text, Position position, Color color) { + write(text, color, position.xinPixels - 80, position.yinPixels + TEXT_SIZE) + } def writeAttributes(String text, Position position, Color color) { val lines = text.split("[\n|\r]").length