<commit_before>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package net.sekien.elesmyr.ui;

import net.sekien.elesmyr.msgsys.MessageEndPoint;
import net.sekien.elesmyr.player.Camera;
import net.sekien.elesmyr.system.GameClient;
import net.sekien.elesmyr.system.Main;
import net.sekien.elesmyr.util.FileHandler;
import net.sekien.pepper.Renderer;
import org.newdawn.slick.*;

import java.util.LinkedList;
import java.util.List;

public class DMSGUI implements UserInterface {
	private boolean inited = false;
	private static LinkedList<DMessage> msgBuffer;
	private Image msg;

	@Override public boolean inited() { return inited; }

	public DMSGUI() {
		msgBuffer = new LinkedList<DMessage>();
	}

	@Override public void init(GameContainer gc, MessageEndPoint receiver) throws SlickException {
		inited = true;
		msg = FileHandler.getImage("ui.msg");
		displayMessage("Loaded!", null);
		displayMessage("Obtained Gold Sword!", "item.swordgold");
		displayMessage("Obtained Egg!", "item.egg");
		displayMessage("Msg3!", null);
	}

	@Override public void render(Renderer renderer, Camera cam, GameClient receiver) throws SlickException {
		int i = 0;
		for (DMessage dmsg : msgBuffer) {
			float anim_enter = Math.min(20, 200-dmsg.getTime())/20f;
			float anim_leave = Math.min(20, dmsg.getTime())/20f;
			Color alpha = new Color(1, 1, 1, anim_leave);

			int yoffset = (int) (i+(anim_enter-1)*msg.getHeight());
			renderer.pushPos(Main.INTERNAL_RESX-msg.getWidth(), yoffset);
			msg.draw(0, 0, alpha);
			if (dmsg.hasImage()) {
				dmsg.getImage().draw(8, 8, alpha);
				renderer.text(48, 8, dmsg.getText(), alpha);
			} else {
				renderer.text(8, 8, dmsg.getText(), alpha);
			}
			i = yoffset+msg.getHeight();
			renderer.popPos();
		}
	}

	@Override public void update(GameContainer gc, GameClient receiver) {
		List<DMessage> removeMessages = new LinkedList<DMessage>();
		for (DMessage dmsg : msgBuffer) {
			if (dmsg.update()) {
				removeMessages.add(dmsg);
			}
		}
		msgBuffer.removeAll(removeMessages);
	}
<commit_msg>Changed the design of the message system<commit_after>/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

/*
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package net.sekien.elesmyr.ui;

import net.sekien.elesmyr.msgsys.MessageEndPoint;
import net.sekien.elesmyr.player.Camera;
import net.sekien.elesmyr.system.FontRenderer;
import net.sekien.elesmyr.system.GameClient;
import net.sekien.elesmyr.system.Main;
import net.sekien.elesmyr.util.FileHandler;
import net.sekien.pepper.Renderer;
import org.newdawn.slick.*;

import java.util.LinkedList;
import java.util.List;

public class DMSGUI implements UserInterface {
	private boolean inited = false;
	private static LinkedList<DMessage> msgBuffer;
	private Image msg;

	@Override public boolean inited() { return inited; }

	public DMSGUI() {
		msgBuffer = new LinkedList<DMessage>();
	}

	@Override public void init(GameContainer gc, MessageEndPoint receiver) throws SlickException {
		inited = true;
		msg = FileHandler.getImage("ui.hud.msg");
		displayMessage("Loaded!", null);
		displayMessage("Obtained Gold Sword!", "item.swordgold");
		displayMessage("Obtained Egg!", "item.egg");
		displayMessage("Msg3!", null);
	}

	@Override public void render(Renderer renderer, Camera cam, GameClient receiver) throws SlickException {
		int i = 0;
        Graphics g = renderer.g;
        if(msgBuffer.size()>0) {
            msg.draw(Main.INTERNAL_RESX-360, 0);
        }
		for (DMessage dmsg : msgBuffer) {
			float anim_enter = Math.min(20, 200-dmsg.getTime())/20f;
			float anim_leave = Math.min(20, dmsg.getTime())/20f;
			Color alpha = new Color(1, 1, 1, anim_leave);

			int yoffset = (int) (i+(anim_enter-1));
			renderer.pushPos(Main.INTERNAL_RESX-256, yoffset);
            FontRenderer.drawStringFlat(248-FontRenderer.getStringWidth(dmsg.getText()), 8, dmsg.getText(), alpha,g);
			i = yoffset+20;
			renderer.popPos();
		}
	}

	@Override public void update(GameContainer gc, GameClient receiver) {
		List<DMessage> removeMessages = new LinkedList<DMessage>();
		for (DMessage dmsg : msgBuffer) {
			if (dmsg.update()) {
				removeMessages.add(dmsg);
			}
		}
		msgBuffer.removeAll(removeMessages);
	}

{'fraction_non_alphanumeric': 0.12704918032786885, 'fraction_numerical': 0.014959016393442623, 'mean_word_length': 4.100313479623824, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5098318', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1615, 'n_words': 437}