MineLittlePony/src/main/java/com/minelittlepony/client/hdskins/GuiSkinsMineLP.java

92 lines
3.1 KiB
Java
Raw Normal View History

2019-11-23 23:19:13 +02:00
package com.minelittlepony.client.hdskins;
2015-08-01 18:36:33 -04:00
import com.minelittlepony.api.pony.IPony;
import com.minelittlepony.client.GuiPonySettings;
import com.minelittlepony.client.MineLittlePony;
import com.minelittlepony.common.client.gui.element.Button;
import com.minelittlepony.common.client.gui.sprite.TextureSprite;
2020-01-28 12:40:44 +02:00
import com.minelittlepony.hdskins.client.dummy.PlayerPreview;
import com.minelittlepony.hdskins.client.gui.GuiSkins;
2020-03-27 20:14:50 +02:00
import com.minelittlepony.hdskins.server.SkinServerList;
import com.minelittlepony.hdskins.profile.SkinType;
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
2018-09-06 13:44:41 +02:00
import net.minecraft.client.gui.screen.Screen;
2019-05-27 17:59:15 +02:00
import net.minecraft.util.Identifier;
2015-08-01 18:36:33 -04:00
import org.lwjgl.glfw.GLFW;
/**
* Skin uploading GUI. Usually displayed over the main menu.
*/
2019-12-09 17:44:47 +02:00
class GuiSkinsMineLP extends GuiSkins {
2015-08-01 18:36:33 -04:00
2022-11-23 21:32:25 +00:00
private static final String[] PANORAMAS = new String[] {
2019-04-14 13:32:01 +02:00
"minelittlepony:textures/cubemap/sugarcubecorner",
"minelittlepony:textures/cubemap/quillsandsofas",
"minelittlepony:textures/cubemap/sweetappleacres"
};
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
super(parent, servers);
}
@Override
public void init() {
super.init();
if (!(parent instanceof GuiPonySettings)) {
addButton(new Button(width - 25, height - 90, 20, 20))
2021-11-25 00:09:34 +02:00
.onClick(sender -> client.setScreen(new GuiPonySettings(this)))
.getStyle()
.setIcon(new TextureSprite()
.setPosition(2, 2)
.setTexture(new Identifier("minelittlepony", "textures/gui/pony.png"))
.setTextureSize(16, 16)
.setSize(16, 16))
.setTooltip("minelp.options.title", 0, 10);
}
}
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (modifiers == (GLFW.GLFW_MOD_ALT | GLFW.GLFW_MOD_CONTROL) && keyCode == GLFW.GLFW_KEY_R) {
client.reloadResources();
return true;
}
return super.keyPressed(keyCode, scanCode, modifiers);
}
2015-08-01 18:36:33 -04:00
@Override
public PlayerPreview createPreviewer() {
return new PonyPreview();
2015-08-01 18:36:33 -04:00
}
@Override
2019-05-27 17:59:15 +02:00
protected Identifier getBackground() {
2022-11-23 21:32:25 +00:00
int i = (int)Math.floor(Math.random() * PANORAMAS.length);
2022-11-23 21:32:25 +00:00
return new Identifier(PANORAMAS[i]);
}
2015-08-01 18:36:33 -04:00
@Override
2019-08-23 11:12:20 +02:00
public void onSetLocalSkin(SkinType type) {
super.onSetLocalSkin(type);
2018-08-22 21:55:30 +02:00
2016-11-24 23:40:19 -05:00
MineLittlePony.logger.debug("Invalidating old local skin, checking updated local skin");
2019-08-23 11:12:20 +02:00
if (type == SkinType.SKIN) {
previewer.getLocal().ifPresent(local -> IPony.getManager().removePony(local.getTextures().get(SkinType.SKIN).getId()));
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
@Override
2019-08-23 11:12:20 +02:00
public void onSetRemoteSkin(SkinType type, Identifier location, MinecraftProfileTexture profileTexture) {
super.onSetRemoteSkin(type, location, profileTexture);
2016-12-21 01:20:02 -05:00
MineLittlePony.logger.debug("Invalidating old remote skin, checking updated remote skin");
2019-08-23 11:12:20 +02:00
if (type == SkinType.SKIN) {
IPony.getManager().removePony(location);
2017-06-16 01:41:36 -04:00
}
2015-08-01 18:36:33 -04:00
}
}