2019-11-23 23:19:13 +02:00
|
|
|
package com.minelittlepony.client.hdskins;
|
2015-08-01 18:36:33 -04:00
|
|
|
|
2022-12-11 00:38:00 +00:00
|
|
|
import com.minelittlepony.api.pony.IPony;
|
2021-05-17 23:27:21 +02:00
|
|
|
import com.minelittlepony.client.GuiPonySettings;
|
2019-07-07 22:47:13 -04:00
|
|
|
import com.minelittlepony.client.MineLittlePony;
|
2021-05-17 23:27:21 +02:00
|
|
|
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;
|
2018-08-18 23:44:32 -04:00
|
|
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
2018-09-06 13:44:41 +02:00
|
|
|
|
2019-07-16 17:52:39 +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
|
|
|
|
2022-06-11 18:22:35 +02:00
|
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
|
2018-04-25 21:29:49 +02:00
|
|
|
/**
|
|
|
|
* 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"
|
2018-07-05 22:49:28 -04:00
|
|
|
};
|
|
|
|
|
2019-07-16 17:52:39 +02:00
|
|
|
public GuiSkinsMineLP(Screen parent, SkinServerList servers) {
|
|
|
|
super(parent, servers);
|
2018-08-19 17:55:38 -04:00
|
|
|
}
|
|
|
|
|
2021-05-17 23:27:21 +02:00
|
|
|
@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)))
|
2021-05-17 23:27:21 +02:00
|
|
|
.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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-11 18:22:35 +02:00
|
|
|
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
|
2019-05-28 14:47:21 +02:00
|
|
|
public PlayerPreview createPreviewer() {
|
|
|
|
return new PonyPreview();
|
2015-08-01 18:36:33 -04:00
|
|
|
}
|
|
|
|
|
2018-07-01 17:33:30 +02: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);
|
2018-07-05 22:49:28 -04:00
|
|
|
|
2022-11-23 21:32:25 +00:00
|
|
|
return new Identifier(PANORAMAS[i]);
|
2018-07-01 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
2015-08-01 18:36:33 -04:00
|
|
|
@Override
|
2019-08-23 11:12:20 +02:00
|
|
|
public void onSetLocalSkin(SkinType type) {
|
2018-08-21 21:18:20 +02:00
|
|
|
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) {
|
2022-12-11 00:38:00 +00:00
|
|
|
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) {
|
2018-08-21 21:18:20 +02:00
|
|
|
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) {
|
2022-12-11 00:38:00 +00:00
|
|
|
IPony.getManager().removePony(location);
|
2017-06-16 01:41:36 -04:00
|
|
|
}
|
2015-08-01 18:36:33 -04:00
|
|
|
}
|
|
|
|
}
|