Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.noneatme.littleFighter.classes.guis;
- import org.newdawn.slick.Color;
- import org.newdawn.slick.Font;
- import org.newdawn.slick.Graphics;
- import org.newdawn.slick.Image;
- import org.newdawn.slick.Input;
- import org.newdawn.slick.gui.GUIContext;
- import org.newdawn.slick.gui.MouseOverArea;
- import org.newdawn.slick.util.FontUtils;
- import de.noneatme.littleFighter.classes.cGameSettings;
- import de.noneatme.littleFighter.classes.manager.cFontManager;
- public class BasicButton extends MouseOverArea
- {
- private String title;
- private Font font;
- private Color fontColor = Color.black;
- private Image normalImage;
- private Image mouseOverImage;
- @SuppressWarnings("unused")
- private Image mouseDownImage;
- public BasicButton(GUIContext container, Font font, int x, int y, int w, int h, String title)
- {
- super(container, null, x, y, w, h);
- this.font = font;
- this.setNormalImage(cGameSettings.imgManager.getImage(1001));
- this.setMouseOverImage(cGameSettings.imgManager.getImage(1002));
- this.setMouseDownImage(cGameSettings.imgManager.getImage(1002));
- this.setTitle(title);
- }
- public void setTitle(String title)
- {
- this.title = title;
- }
- public String getTitle()
- {
- return this.title;
- }
- public void setNormalImage(Image img)
- {
- this.normalImage = img;
- }
- public void setMouseOverImage(Image img)
- {
- this.mouseOverImage = img;
- }
- public void setMouseDownImage(Image img)
- {
- this.mouseDownImage = img;
- }
- public void render(GUIContext cont, Graphics graph)
- {
- Image usedImage;
- if(this.isMouseOver())
- {
- usedImage = this.mouseOverImage;
- this.setFocus(true);
- }
- else
- {
- usedImage = this.normalImage;
- this.setFocus(false);
- }
- graph.drawImage(usedImage.getScaledCopy(this.getWidth(), this.getHeight()), this.getX(), this.getY());
- // Text //
- graph.setColor(this.fontColor);
- FontUtils.drawCenter(this.font, this.getTitle(), this.getX(), (this.getY()+(this.getHeight()/2))-cFontManager.BUTTON_FONT.getHeight()/2, this.getWidth());
- }
- public void mouseClicked(int button, int x, int y, int clickAmmount)
- {
- if(this.hasFocus())
- {
- if(button == Input.MOUSE_LEFT_BUTTON)
- {
- this.notifyListeners();
- }
- }
- }
- }
- /*
- *
- *
- * Vornoten: DE 4, EN 3, Rechnernetze 2, Energiesysteme Bla 4, Datenbanken 2, LF6 1, Mathe 4
- */
Advertisement
Add Comment
Please, Sign In to add comment