the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 84 lines 1.9 kB view raw
1#include "stdafx.h" 2#include "Stitcher.h" 3#include "Texture.h" 4#include "..\Minecraft.World\StringHelpers.h" 5#include "TextureHolder.h" 6 7TextureHolder::TextureHolder(Texture *texture) 8{ 9 scale = 1.0f; 10 11 this->texture = texture; 12 this->width = texture->getWidth(); 13 this->height = texture->getHeight(); 14 15 this->rotated = smallestFittingMinTexel(height) > smallestFittingMinTexel(width); 16} 17 18Texture *TextureHolder::getTexture() 19{ 20 return texture; 21} 22 23int TextureHolder::getWidth() const 24{ 25 return rotated ? smallestFittingMinTexel((int) (height * scale)) : smallestFittingMinTexel((int) (width * scale)); 26} 27 28int TextureHolder::getHeight() const 29{ 30 return rotated ? smallestFittingMinTexel((int) (width * scale)) : smallestFittingMinTexel((int) (height * scale)); 31} 32 33void TextureHolder::rotate() 34{ 35 rotated = !rotated; 36} 37 38bool TextureHolder::isRotated() 39{ 40 return rotated; 41} 42 43int TextureHolder::smallestFittingMinTexel(int input) const 44{ 45 return ((input >> Stitcher::MAX_MIPLEVEL) + ((input & (Stitcher::MIN_TEXEL - 1)) == 0 ? 0 : 1)) << Stitcher::MAX_MIPLEVEL; 46} 47 48void TextureHolder::setForcedScale(int targetSize) 49{ 50 if (width <= targetSize || height <= targetSize) 51 { 52 return; 53 } 54 55 scale = (float) targetSize / min(width, height); 56} 57 58//@Override 59wstring TextureHolder::toString() 60{ 61 return L"TextureHolder{width=" + _toString(width) + L", height=" + _toString(height) + L'}'; 62} 63 64int TextureHolder::compareTo(const TextureHolder *other) const 65{ 66 int result = 0; 67 if (this->getHeight() == other->getHeight()) 68 { 69 if (this->getWidth() == other->getWidth()) 70 { 71 if (texture->getName().empty()) 72 { 73 return other->texture->getName().empty() ? 0 : -1; 74 } 75 return texture->getName().compare(other->texture->getName()); 76 } 77 result = this->getWidth() < other->getWidth() ? 1 : -1; 78 } 79 else 80 { 81 result = this->getHeight() < other->getHeight() ? 1 : -1; 82 } 83 return result; 84}