Created
November 27, 2021 03:01
-
-
Save SuperSkidder/86c1ddd523e53f408dd0edfcad893193 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.superskidder.fpsmaster.client.gui.notification; | |
import java.util.ArrayList; | |
public class NotificationsManager { | |
public ArrayList<Notification> notifications = new ArrayList<Notification>(); | |
public void add(Notification noti) { | |
noti.y = notifications.size() * 25; | |
notifications.add(noti); | |
} | |
public void draw() { | |
int i = 0; | |
Notification remove = null; | |
for (Notification notification : notifications) { | |
// if (i == 0) { | |
if (notification.x == 0) { | |
notification.in = !notification.in; | |
} | |
if (Math.abs(notification.x - notification.width) < 0.1 && !notification.in) { | |
remove = notification; | |
} | |
if (notification.in) { | |
notification.x = (float) notification.animationUtils.animate(0, notification.x, 0.1f); | |
} else { | |
notification.x = (float) notification.animationUtils.animate(notification.width, notification.x, 0.1f); | |
} | |
// } | |
notification.onRender(); | |
i++; | |
} | |
if (remove != null) { | |
notifications.remove(remove); | |
} | |
} | |
} | |
package me.superskidder.fpsmaster.client.gui.notification; | |
import me.superskidder.fpsmaster.FpsMaster; | |
import me.superskidder.fpsmaster.utils.AnimationUtils; | |
import me.superskidder.fpsmaster.utils.RenderUtil; | |
import net.minecraft.client.gui.ScaledResolution; | |
import java.awt.*; | |
public class Notification { | |
public String text; | |
public double width, height = 30; | |
public float x; | |
Type type; | |
public float y, position; | |
public boolean in = true; | |
AnimationUtils animationUtils = new AnimationUtils(); | |
AnimationUtils yAnimationUtils = new AnimationUtils(); | |
public Notification(String text, Type type) { | |
this.text = text; | |
this.type = type; | |
width = FpsMaster.INSTANCE.fontLoaders.msFont18.getStringWidth(text) + 25; | |
x = (float) width; | |
} | |
public void onRender() { | |
int i = 0; | |
for (Notification notification : FpsMaster.INSTANCE.notificationsManager.notifications) { | |
if (notification == this) { | |
break; | |
} | |
i++; | |
} | |
y = yAnimationUtils.animate((float) ((float) i * (height + 5)), y, 0.1f); | |
ScaledResolution sr = new ScaledResolution(FpsMaster.INSTANCE.mc); | |
RenderUtil.drawRect(sr.getScaledWidth() + x - width, sr.getScaledHeight() - 50 - y - height, sr.getScaledWidth() + x, sr.getScaledHeight() - 50 - y, new Color(0, 0, 0, 165)); | |
RenderUtil.drawShadow((float) (sr.getScaledWidth() + x - width), (float) (sr.getScaledHeight() - 50 - y - height), sr.getScaledWidth() + x, sr.getScaledHeight() - 50 - y, 5); | |
FpsMaster.INSTANCE.fontLoaders.msFont18.drawStringWithShadow(text, ((float) (sr.getScaledWidth() + x - width + 10)), ((float) (sr.getScaledHeight() - 50f - y - 18)), new Color(204, 204, 204, 232).getRGB()); | |
} | |
public enum Type { | |
Success, | |
Error, | |
Info | |
} | |
} | |
package me.superskidder.fpsmaster.modules.render; | |
import me.superskidder.fpsmaster.FpsMaster; | |
import me.superskidder.fpsmaster.client.gui.notification.NotificationsManager; | |
import me.superskidder.fpsmaster.core.Module; | |
import me.superskidder.fpsmaster.core.ModuleCategory; | |
import me.superskidder.fpsmaster.event.EventTarget; | |
import me.superskidder.fpsmaster.event.events.impl.render.EventRender2D; | |
public class NotificationModule extends Module { | |
public NotificationModule(String name, String desc) { | |
super(name, desc, ModuleCategory.Renders); | |
} | |
@EventTarget | |
public void onRender2D(EventRender2D e){ | |
FpsMaster.INSTANCE.notificationsManager.draw(); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's Good