Ejemplo n.º 1
0
	@Override
	public String getState() {
		IJsonServices json = playerServices.getJsonServices();
		HashMap<String, String> state = new HashMap<String, String>();

		state.put("isVisible", Boolean.toString(isVisible));
		
		return json.toJSONString(state);
	}
Ejemplo n.º 2
0
	@Override
	public void setState(String state) {
		IJsonServices json = playerServices.getJsonServices();
		HashMap<String, String> decodedState = json.decodeHashMap(state);
		
		if (decodedState.containsKey("isVisible")) {
			isVisible = Boolean.parseBoolean(decodedState.get("isVisible"));
			if (isVisible) {
				show();
			} else {
				hide();
			}
		}
	}
Ejemplo n.º 3
0
	@Override
	public String getState() {
		IJsonServices json = playerServices.getJsonServices();
		HashMap<String, String> state = new HashMap<String, String>();
		if (consumedItem != null) {
			state.put("consumed",  consumedItem.toString());
		}
		state.put("isVisible", Boolean.toString(isVisible));
		if (isShowErrorsMode) {
			state.put("isDisabled", Boolean.toString(workModeDisabled));
		} else if (this.isShowAnswersActive) {
			state.put("isDisabled", Boolean.toString(showAnswersModeDisabled));
		} else {
			state.put("isDisabled", Boolean.toString(view.getDisabled()));
		}

		return json.toJSONString(state);
	}
Ejemplo n.º 4
0
	@Override
	public void setState(String stateObj) {
		IJsonServices json = playerServices.getJsonServices();
		HashMap<String, String> state = json.decodeHashMap(stateObj);
		if (state.containsKey("consumed")) {
			consumedItem = DraggableItem.createFromString(state.get("consumed"));
			view.setImageUrl(getImageURL(consumedItem));
			view.makeDraggable(this);
		}
		if (state.containsKey("isVisible")) {
			if (Boolean.parseBoolean(state.get("isVisible"))) {
				show();
			} else {
				hide();
			}
		}

		if (state.containsKey("isDisabled")) {
			view.setDisabled(Boolean.parseBoolean(state.get("isDisabled")));
		}
	}