use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.
the class ItemStackRenderHelper method renderSkinWithHelper.
public static void renderSkinWithHelper(Skin skin, ISkinPointer skinPointer, boolean showSkinPaint, boolean doLodLoading) {
ISkinType skinType = skinPointer.getIdentifier().getSkinType();
if (skinType == null) {
skinType = skin.getSkinType();
}
IEquipmentModel targetModel = SkinModelRenderer.INSTANCE.getModelForEquipmentType(skinType);
if (targetModel == null) {
renderSkinWithoutHelper(skinPointer, doLodLoading);
return;
}
targetModel.render(null, null, skin, showSkinPaint, skinPointer.getSkinDye(), null, true, 0, doLodLoading);
}
use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.
the class ItemSkinUnlock method onItemRightClick.
@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) {
if (world.isRemote) {
return itemStack;
}
ISkinType skinType = getSkinTypeFormStack(itemStack);
ExPropsPlayerSkinData equipmentData = ExPropsPlayerSkinData.get(player);
int count = equipmentData.getEquipmentWardrobeData().getUnlockedSlotsForSkinType(skinType);
count++;
String localizedSkinName = SkinTypeRegistry.INSTANCE.getLocalizedSkinTypeName(skinType);
if (count <= ExPropsPlayerSkinData.MAX_SLOTS_PER_SKIN_TYPE) {
equipmentData.setSkinColumnCount(skinType, count);
player.addChatComponentMessage(new ChatComponentTranslation("chat.armourersworkshop:slotUnlocked", localizedSkinName.toLowerCase(), Integer.toString(count)));
itemStack.stackSize--;
} else {
player.addChatComponentMessage(new ChatComponentTranslation("chat.armourersworkshop:slotUnlockedFailed", localizedSkinName));
}
return itemStack;
}
use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.
the class LibraryFileList method updateTypeLists.
private void updateTypeLists() {
ArrayList<ISkinType> skinTypes = SkinTypeRegistry.INSTANCE.getRegisteredSkinTypes();
synchronized (typeListsMap) {
typeListsMap.clear();
for (int i = 0; i < skinTypes.size(); i++) {
ISkinType skinType = skinTypes.get(i);
ArrayList<LibraryFile> typeList = getFileListForSkinType(skinType);
typeListsMap.put(skinType.getRegistryName(), typeList);
}
ModLogger.log(String.format("Created %d type lists for file list type %s.", typeListsMap.size(), this.listType.toString()));
}
}
use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.
the class LibraryHelper method getSkinFilesInDirectory.
public static ArrayList<LibraryFile> getSkinFilesInDirectory(File directory, boolean subDirectories) {
ArrayList<LibraryFile> fileList = new ArrayList<LibraryFile>();
if (!directory.exists() | !directory.isDirectory()) {
return fileList;
}
File libraryDir = SkinIOUtils.getSkinLibraryDirectory();
File[] templateFiles;
try {
templateFiles = directory.listFiles();
} catch (Exception e) {
ModLogger.log(Level.ERROR, "Armour file list load failed.");
e.printStackTrace();
return fileList;
}
for (int i = 0; i < templateFiles.length; i++) {
if (templateFiles[i].getName().endsWith(".armour")) {
String cleanName = FilenameUtils.removeExtension(templateFiles[i].getName());
String path = templateFiles[i].getPath().replace(templateFiles[i].getName(), "");
path = path.replace(libraryDir.getPath(), "");
ISkinType skinType = SkinIOUtils.getSkinTypeNameFromFile(templateFiles[i]);
if (skinType != null) {
fileList.add(new LibraryFile(cleanName, path, skinType));
}
} else {
if (templateFiles[i].isDirectory()) {
String name = templateFiles[i].getName();
String path = templateFiles[i].getParent() + "/";
path = path.replace(SkinIOUtils.getSkinLibraryDirectory().getPath(), "");
path = path.replace("\\", "/");
if (!name.equals("private")) {
fileList.add(new LibraryFile(templateFiles[i].getName(), path, null, true));
}
}
}
}
Collections.sort(fileList);
if (subDirectories) {
for (int i = 0; i < templateFiles.length; i++) {
if (templateFiles[i].isDirectory()) {
fileList.addAll(getSkinFilesInDirectory(templateFiles[i], true));
}
}
}
return fileList;
}
use of riskyken.armourersWorkshop.api.common.skin.type.ISkinType in project Armourers-Workshop by RiskyKen.
the class GuiSkinLibrary method drawScreen.
@Override
public void drawScreen(int mouseX, int mouseY, float partialTickTime) {
int oldMouseX = mouseX;
int oldMouseY = mouseY;
if (isDialogOpen()) {
mouseX = mouseY = 0;
}
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
super.drawScreen(mouseX, mouseY, partialTickTime);
GL11.glPopAttrib();
ILibraryManager libraryManager = ArmourersWorkshop.proxy.libraryManager;
ArrayList<LibraryFile> files = libraryManager.getServerPublicFileList().getFileList();
loadSaveButton.enabled = true;
if (isLoading()) {
loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "load");
if (fileList.getSelectedListEntry() == null || ((GuiFileListItem) fileList.getSelectedListEntry()).getFile().directory) {
loadSaveButton.displayString = "";
loadSaveButton.enabled = false;
}
} else {
loadSaveButton.displayString = GuiHelper.getLocalizedControlName(armourLibrary.getInventoryName(), "save");
}
if (!((Slot) inventorySlots.inventorySlots.get(36)).getHasStack() & !armourLibrary.isCreativeLibrary()) {
loadSaveButton.displayString = "";
loadSaveButton.enabled = false;
}
if (fileSwitchType == LibraryFileType.LOCAL) {
files = libraryManager.getClientPublicFileList().getFileList();
if (!mc.isIntegratedServerRunning()) {
loadSaveButton.enabled = false;
if (isLoading()) {
loadSaveButton.enabled = ConfigHandler.allowClientsToUploadSkins;
} else {
loadSaveButton.enabled = ConfigHandler.allowClientsToDownloadSkins;
}
}
} else {
loadSaveButton.enabled = true;
}
if (fileSwitchType == LibraryFileType.SERVER_PRIVATE) {
files = libraryManager.getServerPrivateFileList(mc.thePlayer).getFileList();
}
String typeFilter = dropDownList.getListSelectedItem().tag;
ISkinType skinTypeFilter = SkinTypeRegistry.INSTANCE.getSkinTypeFromRegistryName(typeFilter);
lastSkinType = skinTypeFilter;
lastSearchText = searchTextbox.getText();
IGuiListItem selectedItem = fileList.getSelectedListEntry();
if (selectedItem != null) {
// deleteButton.enabled = !((GuiFileListItem)selectedItem).getFile().readOnly;
} else {
// deleteButton.enabled = false;
}
fileList.setSelectedIndex(-1);
fileList.clearList();
if (!(currentFolder.equals("/") | currentFolder.equals(getPrivateRoot(player)))) {
fileList.addListItem(new GuiFileListItem(new LibraryFile("../", "", null, true)));
if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile().fileName.equals("../")) {
fileList.setSelectedIndex(0);
}
}
if (files != null) {
for (int i = 0; i < files.size(); i++) {
LibraryFile file = files.get(i);
if (skinTypeFilter == null | skinTypeFilter == file.skinType) {
if (file.filePath.equals(currentFolder)) {
if (!searchTextbox.getText().equals("")) {
if (file.fileName.toLowerCase().contains(searchTextbox.getText().toLowerCase())) {
fileList.addListItem(new GuiFileListItem(file));
if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
fileList.setSelectedIndex(fileList.getSize() - 1);
}
}
} else {
fileList.addListItem(new GuiFileListItem(file));
if (selectedItem != null && ((GuiFileListItem) selectedItem).getFile() == file) {
fileList.setSelectedIndex(fileList.getSize() - 1);
}
}
}
}
}
}
scrollAmount = scrollbar.getValue();
fileList.setScrollPercentage(scrollbar.getPercentageValue());
for (int i = 0; i < buttonList.size(); i++) {
GuiButton button = (GuiButton) buttonList.get(i);
if (button instanceof GuiIconButton) {
((GuiIconButton) button).drawRollover(mc, mouseX, mouseY);
}
}
if (showModelPreviews()) {
GuiFileListItem item = (GuiFileListItem) fileList.getSelectedListEntry();
if (item != null && !item.getFile().isDirectory()) {
SkinIdentifier identifier = new SkinIdentifier(0, new LibraryFile(item.getFile().getFullName()), 0, null);
Skin skin = ClientSkinCache.INSTANCE.getSkin(identifier, true);
if (skin != null) {
SkinPointer skinPointer = new SkinPointer(identifier);
int listRight = this.width - INVENTORY_WIDTH - PADDING * 5;
listRight = MathHelper.clamp_int(listRight, 0, 200);
listRight += INVENTORY_WIDTH + PADDING * 2 + 10;
int listTop = TITLE_HEIGHT + 14 + PADDING * 2;
int xSize = (this.width - listRight - PADDING) / 2;
int ySize = (this.height - listTop - PADDING) / 2;
float x = listRight + xSize;
float y = listTop + ySize;
float scale = 1F;
scale = 1 * Math.min(xSize, ySize);
ScaledResolution scaledResolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
int startX = listRight + PADDING;
int startY = listTop + PADDING;
int tarW = (int) (x + xSize);
int tarH = (int) (y + ySize);
drawRect(startX, startY, tarW, tarH, 0x77777777);
if (scale > 8) {
GL11.glPushMatrix();
GL11.glTranslatef((float) x, (float) y, 500.0F);
GL11.glScalef(10, 10, -10);
GL11.glRotatef(30, 1, 0, 0);
GL11.glRotatef(45, 0, 1, 0);
float rotation = (float) ((double) System.currentTimeMillis() / 10 % 360);
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
RenderHelper.enableStandardItemLighting();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
GL11.glEnable(GL11.GL_NORMALIZE);
GL11.glEnable(GL11.GL_COLOR_MATERIAL);
ModRenderHelper.enableAlphaBlend();
SkinItemRenderHelper.renderSkinAsItem(skin, skinPointer, true, false, tarW - startX, tarH - startY);
GL11.glPopAttrib();
GL11.glPopMatrix();
}
}
}
}
GL11.glColor4f(1, 1, 1, 1);
if (isDialogOpen()) {
this.dialog.draw(oldMouseX, oldMouseY, partialTickTime);
}
}
Aggregations