mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-06-04 03:26:35 +00:00
chore: format Minecraft.Client
This commit is contained in:
@@ -4,81 +4,65 @@
|
||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||
#include "TextureHolder.h"
|
||||
|
||||
TextureHolder::TextureHolder(Texture *texture)
|
||||
{
|
||||
scale = 1.0f;
|
||||
TextureHolder::TextureHolder(Texture* texture) {
|
||||
scale = 1.0f;
|
||||
|
||||
this->texture = texture;
|
||||
this->width = texture->getWidth();
|
||||
this->height = texture->getHeight();
|
||||
this->texture = texture;
|
||||
this->width = texture->getWidth();
|
||||
this->height = texture->getHeight();
|
||||
|
||||
this->rotated = smallestFittingMinTexel(height) > smallestFittingMinTexel(width);
|
||||
this->rotated =
|
||||
smallestFittingMinTexel(height) > smallestFittingMinTexel(width);
|
||||
}
|
||||
|
||||
Texture *TextureHolder::getTexture()
|
||||
{
|
||||
return texture;
|
||||
Texture* TextureHolder::getTexture() { return texture; }
|
||||
|
||||
int TextureHolder::getWidth() const {
|
||||
return rotated ? smallestFittingMinTexel((int)(height * scale))
|
||||
: smallestFittingMinTexel((int)(width * scale));
|
||||
}
|
||||
|
||||
int TextureHolder::getWidth() const
|
||||
{
|
||||
return rotated ? smallestFittingMinTexel((int) (height * scale)) : smallestFittingMinTexel((int) (width * scale));
|
||||
int TextureHolder::getHeight() const {
|
||||
return rotated ? smallestFittingMinTexel((int)(width * scale))
|
||||
: smallestFittingMinTexel((int)(height * scale));
|
||||
}
|
||||
|
||||
int TextureHolder::getHeight() const
|
||||
{
|
||||
return rotated ? smallestFittingMinTexel((int) (width * scale)) : smallestFittingMinTexel((int) (height * scale));
|
||||
void TextureHolder::rotate() { rotated = !rotated; }
|
||||
|
||||
bool TextureHolder::isRotated() { return rotated; }
|
||||
|
||||
int TextureHolder::smallestFittingMinTexel(int input) const {
|
||||
return ((input >> Stitcher::MAX_MIPLEVEL) +
|
||||
((input & (Stitcher::MIN_TEXEL - 1)) == 0 ? 0 : 1))
|
||||
<< Stitcher::MAX_MIPLEVEL;
|
||||
}
|
||||
|
||||
void TextureHolder::rotate()
|
||||
{
|
||||
rotated = !rotated;
|
||||
}
|
||||
void TextureHolder::setForcedScale(int targetSize) {
|
||||
if (width <= targetSize || height <= targetSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool TextureHolder::isRotated()
|
||||
{
|
||||
return rotated;
|
||||
}
|
||||
|
||||
int TextureHolder::smallestFittingMinTexel(int input) const
|
||||
{
|
||||
return ((input >> Stitcher::MAX_MIPLEVEL) + ((input & (Stitcher::MIN_TEXEL - 1)) == 0 ? 0 : 1)) << Stitcher::MAX_MIPLEVEL;
|
||||
}
|
||||
|
||||
void TextureHolder::setForcedScale(int targetSize)
|
||||
{
|
||||
if (width <= targetSize || height <= targetSize)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scale = (float) targetSize / std::min(width, height);
|
||||
scale = (float)targetSize / std::min(width, height);
|
||||
}
|
||||
|
||||
//@Override
|
||||
std::wstring TextureHolder::toString()
|
||||
{
|
||||
return L"TextureHolder{width=" + _toString(width) + L", height=" + _toString(height) + L'}';
|
||||
std::wstring TextureHolder::toString() {
|
||||
return L"TextureHolder{width=" + _toString(width) + L", height=" +
|
||||
_toString(height) + L'}';
|
||||
}
|
||||
|
||||
int TextureHolder::compareTo(const TextureHolder *other) const
|
||||
{
|
||||
int result = 0;
|
||||
if (this->getHeight() == other->getHeight())
|
||||
{
|
||||
if (this->getWidth() == other->getWidth())
|
||||
{
|
||||
if (texture->getName().empty())
|
||||
{
|
||||
return other->texture->getName().empty() ? 0 : -1;
|
||||
}
|
||||
return texture->getName().compare(other->texture->getName());
|
||||
}
|
||||
result = this->getWidth() < other->getWidth() ? 1 : -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = this->getHeight() < other->getHeight() ? 1 : -1;
|
||||
}
|
||||
return result;
|
||||
int TextureHolder::compareTo(const TextureHolder* other) const {
|
||||
int result = 0;
|
||||
if (this->getHeight() == other->getHeight()) {
|
||||
if (this->getWidth() == other->getWidth()) {
|
||||
if (texture->getName().empty()) {
|
||||
return other->texture->getName().empty() ? 0 : -1;
|
||||
}
|
||||
return texture->getName().compare(other->texture->getName());
|
||||
}
|
||||
result = this->getWidth() < other->getWidth() ? 1 : -1;
|
||||
} else {
|
||||
result = this->getHeight() < other->getHeight() ? 1 : -1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user