Skip to content

Commit

Permalink
i18n, === instead of ==, removing ; from Wollok Game
Browse files Browse the repository at this point in the history
  • Loading branch information
fdodino committed Aug 8, 2018
1 parent fd49c25 commit 39a2242
Show file tree
Hide file tree
Showing 16 changed files with 100 additions and 43 deletions.
3 changes: 2 additions & 1 deletion org.uqbar.project.wollok.game/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Import-Package: org.junit;version="4.11.0",
Bundle-ActivationPolicy: lazy
Require-Bundle: org.eclipse.xtend.lib;bundle-version="2.11.0",
org.apache.log4j,
org.uqbar.project.wollok
org.uqbar.project.wollok,
org.eclipse.osgi
Bundle-ClassPath: lib/gdx-1.6.0.jar,
lib/gdx-backend-lwjgl-1.6.0.jar,
lib/gdx-platform-1.6.0-natives-desktop.jar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BalloonMessage {
var Color color
var long timestamp = 0

new (String aText, Color aColor){
new (String aText, Color aColor) {
text = aText
color = aColor
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Image {
}

override equals(Object obj) {
if(obj == null) return false
if(obj === null) return false

var other = obj as Image
getPath == other.getPath
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CellSize implements ImageSize {
class GameSize implements ImageSize {
Gameboard game

new (Gameboard game) { this.game = game }
new(Gameboard game) { this.game = game }

override width(int originalWidth) { game.pixelWidth }
override height(int originalHeight) { game.pixelHeight }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.uqbar.project.wollok.game;

import java.util.Properties;

import org.eclipse.osgi.util.NLS;
import org.uqbar.project.wollok.utils.WNLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.uqbar.project.wollok.game.messages"; //$NON-NLS-1$

public static String WollokGame_NoMessage;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

public static Properties loadProperties() { return WNLS.load(BUNDLE_NAME, Messages.class); }

private Messages() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class VisualComponent {
window => [
drawMe
drawAttributesIfNecesary
drawBaloonIfNecesary
drawBalloonIfNecesary
]
}

Expand All @@ -45,7 +45,7 @@ abstract class VisualComponent {
}
}

def drawBaloonIfNecesary(Window window) {
def drawBalloonIfNecesary(Window window) {
if (hasMessages)
currentMessage.draw(window, this)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.uqbar.project.wollok.game.helpers.Application
import org.uqbar.project.wollok.game.listeners.ArrowListener
import org.uqbar.project.wollok.game.listeners.GameboardListener
import org.uqbar.project.wollok.interpreter.core.WollokProgramExceptionWrapper
import org.uqbar.project.wollok.game.Messages

@Accessors
class Gameboard {
Expand Down Expand Up @@ -64,13 +65,13 @@ class Gameboard {

def void draw(Window window) {
// NO UTILIZAR FOREACH PORQUE HAY UN PROBLEMA DE CONCURRENCIA AL MOMENTO DE VACIAR LA LISTA
for (var i=0; i < listeners.size(); i++) {
for (var i = 0; i < listeners.size(); i++) {
try
listeners.get(i).notify(this)
catch (WollokProgramExceptionWrapper e) {
var Object message = e.wollokMessage
if (message === null)
message = "NO MESSAGE"
message = Messages.WollokGame_NoMessage

if (character !== null)
character.scream(message.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ import org.uqbar.project.wollok.game.WGPosition
class GameboardInputProcessor implements InputProcessor {

override boolean keyDown(int keycode) {
return false;
return false
}

override boolean keyUp(int keycode) {
return false;
return false
}

override boolean keyTyped(char character) {
return false;
return false
}

override boolean touchDown(int x, int y, int pointer, int button) {
var inverseY = Gameboard.getInstance().pixelHeight() - y;
var inverseY = Gameboard.getInstance().pixelHeight() - y
var position = new WGPosition(x / Gameboard.CELLZISE, inverseY / Gameboard.CELLZISE )

var Iterable<VisualComponent> lista = Gameboard.getInstance.getComponentsInPosition(position)
Expand All @@ -35,56 +35,56 @@ class GameboardInputProcessor implements InputProcessor {
if (button == 1) {
//Gameboard.getInstance.getStage.addActor(MenuBuilder.buildMenu(x, y))
}
return true;
return true
}

override boolean touchUp(int x, int y, int pointer, int button) {
return false;
return false
}

override boolean touchDragged(int x, int y, int pointer) {
return false;
return false
}

override boolean mouseMoved(int x, int y) {
return false;
return false
}

override boolean scrolled(int amount) {
return false;
return false
}

}

public class MenuBuilder {

def static ScrollPane buildMenu(int x, int y) {
var BitmapFont font = new BitmapFont();
font.setUseIntegerPositions(false);
var BitmapFont font = new BitmapFont()
font.setUseIntegerPositions(false)

var LabelStyle lStyle = new LabelStyle();
lStyle.font = font;
var LabelStyle lStyle = new LabelStyle()
lStyle.font = font

var Table mainTable = new Table();
mainTable.defaults().width(80);
var Table mainTable = new Table()
mainTable.defaults().width(80)

var ScrollPane scrollPane = new ScrollPane(mainTable);
scrollPane.setFillParent(false);
scrollPane.setX(x);
scrollPane.setY(y);
var ScrollPane scrollPane = new ScrollPane(mainTable)
scrollPane.setFillParent(false)
scrollPane.setX(x)
scrollPane.setY(y)

var Button b1 = new Button();
b1.add(new Label("Move", lStyle));
b1.left();
mainTable.add(b1);
mainTable.row();
var Button b1 = new Button()
b1.add(new Label("Move", lStyle))
b1.left()
mainTable.add(b1)
mainTable.row()

var Button b2 = new Button();
b2.add(new Label("Attack", lStyle));
b2.left();
mainTable.add(b2);
mainTable.row();
var Button b2 = new Button()
b2.add(new Label("Attack", lStyle))
b2.left()
mainTable.add(b2)
mainTable.row()

return scrollPane;
return scrollPane
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ class GameboardRendering implements ApplicationListener {
}

override create() {
Gdx.input.setInputProcessor(new GameboardInputProcessor());
var camera = new OrthographicCamera(0, 0);
Gdx.input.setInputProcessor(new GameboardInputProcessor())
var camera = new OrthographicCamera(0, 0)
camera.setToOrtho(false, gameboard.pixelWidth(), gameboard.pixelHeight())
this.window = new Window(camera)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Keyboard {
try {
return typeof(Keys).getDeclaredField(aKey.toUpperCase).get(typeof(Integer)) as Integer;
} catch (Exception e) {
// TODO: i18n
throw new RuntimeException("No se encuentra el caracter " + aKey + ".")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
#
#
WollokGame_NoMessage = NO MESSAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Generated by ResourceBundle Editor (http://essiembre.github.io/eclipse-rbe/)
#
#
WollokGame_NoMessage = FALTA MENSAJE
7 changes: 4 additions & 3 deletions org.uqbar.project.wollok.lib/src/wollok/lib/GameObject.xtend
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
package wollok.lib

import org.eclipse.osgi.util.NLS
import org.uqbar.project.wollok.Messages
import org.uqbar.project.wollok.game.gameboard.Gameboard
import org.uqbar.project.wollok.game.listeners.CollisionListener
import org.uqbar.project.wollok.game.listeners.GameboardListener
import org.uqbar.project.wollok.game.listeners.KeyboardListener
import org.uqbar.project.wollok.game.listeners.TimeListener
import org.uqbar.project.wollok.interpreter.core.WollokObject
import org.uqbar.project.wollok.interpreter.core.WollokProgramExceptionWrapper
import org.uqbar.project.wollok.lib.WPosition
import org.uqbar.project.wollok.lib.WVisual

import static org.uqbar.project.wollok.sdk.WollokDSK.*

import static extension org.uqbar.project.wollok.interpreter.nativeobj.WollokJavaConversions.*
import static extension org.uqbar.project.wollok.lib.WollokSDKExtensions.*
import org.uqbar.project.wollok.interpreter.core.WollokProgramExceptionWrapper


/**
*
Expand Down Expand Up @@ -128,7 +129,7 @@ class GameObject {

if (result === null)
// TODO i18n
throw new WollokProgramExceptionWrapper(evaluator.newInstance(EXCEPTION, ("Visual component not found: " + visual).javaToWollok))
throw new WollokProgramExceptionWrapper(evaluator.newInstance(EXCEPTION, NLS.bind(Messages.WollokGame_VisualComponentNotFound, visual).javaToWollok))

result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ public class Messages extends NLS {

public static String WollokTypeSystem_AN_EXPRESSION_IS_EXPECTED_AT_THIS_POSITION;

// ****************************
// ** Wollok Game
// ****************************
public static String WollokGame_VisualComponentNotFound;

static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,18 @@ WollokNumberPreferences_PRINTING_STRATEGY_NOTFOUND = The printing strategy {0} c

WollokTypeSystem_AN_EXPRESSION_IS_EXPECTED_AT_THIS_POSITION = An expression is expected at this position.


# ****************************
# ** Wollok Game
# ****************************

WollokGame_VisualComponentNotFound = Visual component not found on game board: {0}


# ***************************************
# ** Wollok Messages for Native objects
# ***************************************

WollokDictionary_CANNOT_PUT_NULL_KEY = You cannot add an element with a null key in a Dictionary
WollokDictionary_CANNOT_PUT_NULL_VALUE = You cannot add a null value in a Dictionary

Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ WollokNumberPreferences_PRINTING_STRATEGY_NOTFOUND = The printing strategy {0} c

WollokTypeSystem_AN_EXPRESSION_IS_EXPECTED_AT_THIS_POSITION = Se esperaba una expresi\u00F3n.


# ****************************
# ** Wollok Game
# ****************************

WollokGame_VisualComponentNotFound = El componente visual no se encuentra en el tablero: {0}


# ***************************************
# ** Wollok Messages for Native objects
# ***************************************
Expand Down

0 comments on commit 39a2242

Please sign in to comment.