Hey, i created a mod that adds some "Boxes" with information(FPS, CPS, Real world Hour) that you can move wherever you want on the screen, and i'm currently saving the location of the objects in not scaled resolution and rendering them on not scaled resolution, so, when you change from fullscreen to windowed it moves everywhere on the screen, so i was wondering if theres a way to fix this issue, thanks :)!
Renderer of one of those boxes on screen with info.
package com.henixmc.www.coders.infinity.mods.clockmod;
import com.henixmc.www.coders.infinity.mods.keystrokes.KeystrokesMod;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import java.awt.Color;
import java.text.SimpleDateFormat;
import java.util.Date;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiMultiplayer;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.settings.GameSettings;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
public class CLOCKRenderer extends GuiScreen
{
private final Minecraft mc;
int index = 0;
long x = 0L;
public static Color rainbowEffect(float f, float fade)
{
int speed = 10000 / KeystrokesMod.chromaspeed;
int color = Color.HSBtoRGB((float)(System.currentTimeMillis() % speed) / speed, 0.7F, 0.8F);
Color c = new Color(color);
return new Color(c.getRed() / 255.0F * fade, c.getGreen() / 255.0F * fade, c.getBlue() / 255.0F * fade, c.getAlpha() / 255.0F);
}
public CLOCKRenderer()
{
this.mc = Minecraft.getMinecraft();
}
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent event)
{
if ((event.type != RenderGameOverlayEvent.ElementType.TEXT) || (event.isCancelable())) {
return;
}
if (!KeystrokesMod.enabledClock) {
return;
}
if (this.mc.gameSettings.showDebugInfo) {
return;
}
int clockcolor = Integer.MAX_VALUE;
if (KeystrokesMod.ColorsClock == 0)
{
clockcolor = 2130706432;
}
else if (KeystrokesMod.ColorsClock == 1)
{
clockcolor = 2130706602;
}
else if (KeystrokesMod.ColorsClock == 2)
{
clockcolor = 2130749952;
}
else if (KeystrokesMod.ColorsClock == 3)
{
clockcolor = 2130750122;
}
else if (KeystrokesMod.ColorsClock == 4)
{
clockcolor = 2141847552;
}
else if (KeystrokesMod.ColorsClock == 5)
{
clockcolor = 2141847722;
}
else if (KeystrokesMod.ColorsClock == 6)
{
clockcolor = 2147461632;
}
else if (KeystrokesMod.ColorsClock == 7)
{
clockcolor = 2141891242;
}
else if (KeystrokesMod.ColorsClock ==
{
clockcolor = 2136298837;
}
else if (KeystrokesMod.ColorsClock == 9)
{
clockcolor = 2136299007;
}
else if (KeystrokesMod.ColorsClock == 10)
{
clockcolor = 2136342357;
}
else if (KeystrokesMod.ColorsClock == 11)
{
clockcolor = 2136342527;
}
else if (KeystrokesMod.ColorsClock == 12)
{
clockcolor = 2147439957;
}
else if (KeystrokesMod.ColorsClock == 13)
{
clockcolor = 2147440127;
}
else if (KeystrokesMod.ColorsClock == 14)
{
clockcolor = 2147483477;
}
else if (KeystrokesMod.ColorsClock == 15)
{
clockcolor = Integer.MAX_VALUE;
}
else if (KeystrokesMod.ColorsClock == 16)
{
clockcolor = rainbowEffect(this.index + (float)this.x * 4000.0F, 1.0F).getRGB();
}
else if (KeystrokesMod.ColorsClock == 17)
{
Color textdemocolor = new Color(KeystrokesMod.r2, KeystrokesMod.g2, KeystrokesMod.b2, KeystrokesMod.alpha2);
clockcolor = textdemocolor.getRGB();
}
String timeStamp1 = new SimpleDateFormat("hh:mm:ss").format(new Date());
String timeStamp = timeStamp1;
if (KeystrokesMod.BackgroundBox)
{
Color mycolour = new Color(KeystrokesMod.r, KeystrokesMod.g, KeystrokesMod.b, KeystrokesMod.alpha);
Gui.drawRect(KeystrokesMod.coordsClockX, KeystrokesMod.coordsClockY, KeystrokesMod.coordsClockX + 58, KeystrokesMod.coordsClockY + 13, mycolour.getRGB());
this.mc.fontRenderer.drawString(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);
}
if (!KeystrokesMod.BackgroundBox) {
this.mc.fontRenderer.drawStringWithShadow(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);
}
}
}
[/CODE]
Code to move it aroung the screen and save the position:
[CODE]
package com.henixmc.www.coders.infinity.mods.clockmod.settings;
import com.henixmc.www.coders.infinity.mods.keystrokes.Colors;
import com.henixmc.www.coders.infinity.mods.keystrokes.KeystrokesMod;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventBus;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent;
import java.awt.Color;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
public class GuiSettings
extends GuiScreen
{
int index = 0;
long x = 0L;
private boolean isDragging;
private int lastX;
private int lastY;
private GuiButton buttonToggle;
private GuiButton buttonReset;
private GuiButton buttonColor;
private GuiButton buttonColorLeft;
private GuiButton buttonColorRight;
private GuiButton buttonAllign;
private GuiButton BackgroundBoxbutton;
public GuiSettings()
{
this.isDragging = false;
this.lastX = 0;
this.lastY = 0;
}
public static Color rainbowEffect(float f, float fade)
{
int speed = 10000 / KeystrokesMod.chromaspeed;
int color = Color.HSBtoRGB((float)(System.currentTimeMillis() % speed) / speed, 0.7F, 0.8F);
Color c = new Color(color);
return new Color(c.getRed() / 255.0F * fade, c.getGreen() / 255.0F * fade, c.getBlue() / 255.0F * fade, c.getAlpha() / 255.0F);
}
public void initGui()
{
drawCenteredString(this.mc.fontRenderer, "Clock Mod by Infnity", this.width / 2, 4, -1);
this.buttonList.add(this.buttonReset = new GuiButton(0, this.width / 2 - 75, this.height / 2 - 22, 150, 20, "Reset Position"));
this.buttonList.add(this.buttonToggle = new GuiButton(1, this.width / 2 - 75, this.height / 2 - 44, 150, 20, "Enabled: " + KeystrokesMod.enabledClock));
this.buttonList.add(this.buttonColor = new GuiButton(2, this.width / 2 - 75, this.height / 2 + 0, 150, 20, "Color: " + Colors.values()[KeystrokesMod.ColorsClock]));
this.buttonList.add(this.buttonColorRight = new GuiButton(5, this.width / 2 + 76, this.height / 2 + 0, 20, 20, ">"));
this.buttonList.add(this.buttonColorLeft = new GuiButton(6, this.width / 2 - 96, this.height / 2 + 0, 20, 20, "<"));
this.buttonList.add(this.buttonAllign = new GuiButton(3, this.width / 2 - 75, this.height / 2 + 22, 150, 20, "Align under FPS"));
this.buttonList.add(this.BackgroundBoxbutton = new GuiButton(4, this.width / 2 - 75, this.height / 2 + 44, 150, 20, "Background Box: " + KeystrokesMod.BackgroundBox));
}
public void display()
{
FMLCommonHandler.instance().bus().register(this);
}
@SubscribeEvent
public void onClientTick(ClientTickEvent event)
{
FMLCommonHandler.instance().bus().unregister(this);
Minecraft.getMinecraft().displayGuiScreen(this);
}
public void drawScreen(int x, int y, float partialTicks)
{
super.drawDefaultBackground();
int clockcolor = Integer.MAX_VALUE;
if (KeystrokesMod.ColorsClock == 0)
{
clockcolor = 2130706432;
}
else if (KeystrokesMod.ColorsClock == 1)
{
clockcolor = 2130706602;
}
else if (KeystrokesMod.ColorsClock == 2)
{
clockcolor = 2130749952;
}
else if (KeystrokesMod.ColorsClock == 3)
{
clockcolor = 2130750122;
}
else if (KeystrokesMod.ColorsClock == 4)
{
clockcolor = 2141847552;
}
else if (KeystrokesMod.ColorsClock == 5)
{
clockcolor = 2141847722;
}
else if (KeystrokesMod.ColorsClock == 6)
{
clockcolor = 2147461632;
}
else if (KeystrokesMod.ColorsClock == 7)
{
clockcolor = 2141891242;
}
else if (KeystrokesMod.ColorsClock ==
{
clockcolor = 2136298837;
}
else if (KeystrokesMod.ColorsClock == 9)
{
clockcolor = 2136299007;
}
else if (KeystrokesMod.ColorsClock == 10)
{
clockcolor = 2136342357;
}
else if (KeystrokesMod.ColorsClock == 11)
{
clockcolor = 2136342527;
}
else if (KeystrokesMod.ColorsClock == 12)
{
clockcolor = 2147439957;
}
else if (KeystrokesMod.ColorsClock == 13)
{
clockcolor = 2147440127;
}
else if (KeystrokesMod.ColorsClock == 14)
{
clockcolor = 2147483477;
}
else if (KeystrokesMod.ColorsClock == 15)
{
clockcolor = Integer.MAX_VALUE;
}
else if (KeystrokesMod.ColorsClock == 16)
{
clockcolor = rainbowEffect(this.index + (float)this.x * 4000.0F, 1.0F).getRGB();
}
else if (KeystrokesMod.ColorsClock == 17)
{
Color textdemocolor = new Color(KeystrokesMod.r2, KeystrokesMod.g2, KeystrokesMod.b2, KeystrokesMod.alpha2);
clockcolor = textdemocolor.getRGB();
}
Color boxdemocolor = new Color(KeystrokesMod.r, KeystrokesMod.g, KeystrokesMod.b, KeystrokesMod.alpha);
String timeStamp1 = new SimpleDateFormat("hh:mm:ss").format(new Date());
String timeStamp = timeStamp1;
if (KeystrokesMod.BackgroundBox)
{
Gui.drawRect(KeystrokesMod.coordsClockX, KeystrokesMod.coordsClockY, KeystrokesMod.coordsClockX + 58, KeystrokesMod.coordsClockY + 13, boxdemocolor.getRGB());
this.mc.fontRenderer.drawString(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);
}
if (!KeystrokesMod.BackgroundBox) {
this.mc.fontRenderer.drawStringWithShadow(timeStamp, KeystrokesMod.coordsClockX + 9, KeystrokesMod.coordsClockY + 3, clockcolor);
}
drawCenteredString(this.mc.fontRenderer, "ClockMod by Infinity", this.width / 2, 4, -1);
super.drawScreen(x, y, partialTicks);
}
protected void keyTyped(char c, int key)
{
if (key == 1) {
this.mc.displayGuiScreen((GuiScreen)null);
}
}
protected void mouseClicked(int x, int y, int time)
{
String timeStamp = new SimpleDateFormat("hh:mm:ss").format(new Date());
int minX = KeystrokesMod.coordsClockX;
int minY = KeystrokesMod.coordsClockY;
int maxX = KeystrokesMod.coordsClockX + this.fontRendererObj.getStringWidth(timeStamp) + 30;
int maxY = KeystrokesMod.coordsClockY + 12;
if ((x >= minX) && (x <= maxX) && (y >= minY) && (y <= maxY))
{
this.isDragging = true;
this.lastX = x;
this.lastY = y;
}
super.mouseClicked(x, y, time);
}
protected void mouseMovedOrUp(int x, int y, int which)
{
if ((which == 0) && (this.isDragging)) {
this.isDragging = false;
}
super.mouseMovedOrUp(x, y, which);
}
protected void mouseClickMove(int x, int y, int lastButtonClicked, long timeSinceClick)
{
if (this.isDragging)
{
KeystrokesMod.coordsClockX += x - this.lastX;
KeystrokesMod.coordsClockY += y - this.lastY;
this.lastX = x;
this.lastY = y;
}
super.mouseClickMove(x, y, lastButtonClicked, timeSinceClick);
}
protected void actionPerformed(GuiButton button)
{
if (button == this.buttonReset)
{
KeystrokesMod.coordsClockX = 0;
KeystrokesMod.coordsClockY = 0;
}
if (button == this.buttonToggle)
{
KeystrokesMod.enabledClock = !KeystrokesMod.enabledClock;
this.buttonToggle.displayString = ("Enabled: " + KeystrokesMod.enabledClock);
}
if (button == this.BackgroundBoxbutton)
{
KeystrokesMod.BackgroundBox = !KeystrokesMod.BackgroundBox;
this.BackgroundBoxbutton.displayString = ("Background Box: " + KeystrokesMod.BackgroundBox);
}
else if (button == this.buttonColor)
{
KeystrokesMod.ColorsClock += 1;
if (KeystrokesMod.ColorsClock == Colors.values().length) {
KeystrokesMod.ColorsClock = 0;
}
this.buttonColor.displayString = ("Color: " + Colors.values()[KeystrokesMod.ColorsClock]);
}
else if (button == this.buttonColorLeft)
{
KeystrokesMod.ColorsClock -= 1;
if (KeystrokesMod.ColorsClock == -1) {
KeystrokesMod.ColorsClock = 17;
}
this.buttonColor.displayString = ("Color: " + Colors.values()[KeystrokesMod.ColorsClock]);
}
else if (button == this.buttonColorRight)
{
KeystrokesMod.ColorsClock += 1;
if (KeystrokesMod.ColorsClock == Colors.values().length) {
KeystrokesMod.ColorsClock = 17;
}
this.buttonColor.displayString = ("Color: " + Colors.values()[KeystrokesMod.ColorsClock]);
}
else if (button == this.buttonAllign)
{
int cpsx = KeystrokesMod.counterPosXFPS;
int cpsy = KeystrokesMod.counterPosYFPS;
KeystrokesMod.coordsClockX = cpsx;
KeystrokesMod.coordsClockY = cpsy + 15;
}
}
public void onGuiClosed() {
KeystrokesMod.saveSettingsClock();
}
public boolean doesGuiPauseGame()
{
return true;
}
}
[/CODE]