2019-11-23 23:19:13 +02:00
|
|
|
package com.minelittlepony.client.hdskins;
|
2015-08-01 18:36:33 -04:00
|
|
|
|
2019-07-07 22:47:13 -04:00
|
|
|
import com.minelittlepony.client.MineLittlePony;
|
2020-03-29 21:30:43 +02:00
|
|
|
import com.minelittlepony.common.client.gui.element.Cycler;
|
2019-04-14 13:32:01 +02:00
|
|
|
import com.minelittlepony.common.client.gui.style.Style;
|
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;
|
2019-03-23 21:58:50 +02:00
|
|
|
import com.minelittlepony.pony.IPonyManager;
|
2018-08-18 23:44:32 -04:00
|
|
|
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
|
2018-09-06 13:44:41 +02:00
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.item.Items;
|
|
|
|
import net.minecraft.sound.SoundEvents;
|
2019-07-16 17:52:39 +02:00
|
|
|
import net.minecraft.client.gui.screen.Screen;
|
2018-07-01 17:33:30 +02:00
|
|
|
import net.minecraft.item.ItemStack;
|
2019-05-27 17:59:15 +02:00
|
|
|
import net.minecraft.util.Identifier;
|
2015-08-01 18:36:33 -04:00
|
|
|
|
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
|
|
|
|
2019-03-23 20:17:46 +02:00
|
|
|
private IPonyManager ponyManager = MineLittlePony.getInstance().getManager();
|
2016-05-18 05:48:46 -04:00
|
|
|
|
2018-07-01 17:33:30 +02:00
|
|
|
private boolean isWet = false;
|
|
|
|
|
2018-07-05 22:49:28 -04: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
|
|
|
}
|
|
|
|
|
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
|
|
|
public void init() {
|
|
|
|
super.init();
|
2018-07-01 17:33:30 +02:00
|
|
|
|
2020-03-29 21:30:43 +02:00
|
|
|
addButton(new Cycler(width - 25, 142, 20, 20))
|
2019-04-14 13:32:01 +02:00
|
|
|
.setStyles(
|
2019-05-30 21:40:47 +02:00
|
|
|
new Style().setIcon(new ItemStack(Items.BUCKET)).setTooltip("minelp.mode.dry", 0, 10),
|
|
|
|
new Style().setIcon(new ItemStack(Items.WATER_BUCKET)).setTooltip("minelp.mode.wet", 0, 10)
|
2019-04-14 13:32:01 +02:00
|
|
|
)
|
|
|
|
.onChange(this::setWet)
|
|
|
|
.setValue(isWet ? 1 : 0);
|
2018-07-01 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-27 17:59:15 +02:00
|
|
|
protected Identifier getBackground() {
|
2018-07-05 22:49:28 -04:00
|
|
|
int i = (int)Math.floor(Math.random() * panoramas.length);
|
|
|
|
|
2019-05-27 17:59:15 +02:00
|
|
|
return new Identifier(panoramas[i]);
|
2018-07-01 17:33:30 +02:00
|
|
|
}
|
|
|
|
|
2019-04-14 13:32:01 +02:00
|
|
|
protected int setWet(int wet) {
|
2018-08-22 21:55:30 +02:00
|
|
|
playSound(SoundEvents.BLOCK_BREWING_STAND_BREW);
|
2018-07-27 19:42:37 +02:00
|
|
|
|
2019-04-14 13:32:01 +02:00
|
|
|
isWet = wet == 1;
|
2018-07-01 17:33:30 +02:00
|
|
|
|
2019-05-28 19:02:07 +02:00
|
|
|
previewer.getLocal().getTextures().release();;
|
2019-04-14 13:32:01 +02:00
|
|
|
|
2019-05-28 14:47:21 +02:00
|
|
|
if (previewer instanceof PonyPreview) {
|
|
|
|
((PonyPreview)previewer).setWet(isWet);
|
|
|
|
}
|
2019-04-14 13:32:01 +02:00
|
|
|
return wet;
|
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) {
|
|
|
|
ponyManager.removePony(previewer.getLocal().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) {
|
2018-08-21 21:18:20 +02:00
|
|
|
ponyManager.removePony(location);
|
2017-06-16 01:41:36 -04:00
|
|
|
}
|
2015-08-01 18:36:33 -04:00
|
|
|
}
|
|
|
|
}
|