remove Viewport class
This commit is contained in:
+22
-20
@@ -591,9 +591,7 @@ void Hud::setDebug(bool flag) {
|
||||
}
|
||||
|
||||
void Hud::draw(const DrawContext& ctx){
|
||||
const Viewport& viewport = ctx.getViewport();
|
||||
const uint width = viewport.getWidth();
|
||||
const uint height = viewport.getHeight();
|
||||
const auto& viewport = ctx.getViewport();
|
||||
|
||||
bool is_menu_open = menu.hasOpenPage();
|
||||
darkOverlay->setVisible(is_menu_open);
|
||||
@@ -601,8 +599,8 @@ void Hud::draw(const DrawContext& ctx){
|
||||
|
||||
updateElementsPosition(viewport);
|
||||
|
||||
uicamera->setFov(height);
|
||||
uicamera->setAspectRatio(viewport.getRatio());
|
||||
uicamera->setFov(viewport.y);
|
||||
uicamera->setAspectRatio(viewport.x / static_cast<float>(viewport.y));
|
||||
|
||||
auto batch = ctx.getBatch2D();
|
||||
batch->begin();
|
||||
@@ -620,28 +618,28 @@ void Hud::draw(const DrawContext& ctx){
|
||||
int chsizex = texture != nullptr ? texture->getWidth() : 16;
|
||||
int chsizey = texture != nullptr ? texture->getHeight() : 16;
|
||||
batch->rect(
|
||||
(width-chsizex)/2, (height-chsizey)/2,
|
||||
chsizex, chsizey, 0,0, 1,1, 1,1,1,1
|
||||
(viewport.x - chsizex) / 2, (viewport.y - chsizey) / 2,
|
||||
chsizex, chsizey, 0, 0, 1, 1, 1, 1, 1, 1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Hud::updateElementsPosition(const Viewport& viewport) {
|
||||
const uint width = viewport.getWidth();
|
||||
const uint height = viewport.getHeight();
|
||||
|
||||
void Hud::updateElementsPosition(const glm::uvec2& viewport) {
|
||||
if (inventoryOpen) {
|
||||
float caWidth = inventoryView && showContentPanel
|
||||
? contentAccess->getSize().x
|
||||
: 0.0f;
|
||||
contentAccessPanel->setPos(glm::vec2(width-caWidth, 0));
|
||||
contentAccessPanel->setPos(glm::vec2(viewport.x - caWidth, 0));
|
||||
|
||||
glm::vec2 invSize = inventoryView ? inventoryView->getSize() : glm::vec2();
|
||||
if (secondUI == nullptr) {
|
||||
if (inventoryView) {
|
||||
inventoryView->setPos(glm::vec2(
|
||||
glm::min(width/2-invSize.x/2, width-caWidth-10-invSize.x),
|
||||
height/2-invSize.y/2
|
||||
glm::min(
|
||||
viewport.x / 2 - invSize.x / 2,
|
||||
viewport.x - caWidth - 10 - invSize.x
|
||||
),
|
||||
viewport.y / 2 - invSize.y / 2
|
||||
));
|
||||
}
|
||||
} else {
|
||||
@@ -651,17 +649,21 @@ void Hud::updateElementsPosition(const Viewport& viewport) {
|
||||
float totalHeight = invSize.y + secondUISize.y + interval;
|
||||
if (inventoryView) {
|
||||
inventoryView->setPos(glm::vec2(
|
||||
glm::min(width/2-invwidth/2, width-caWidth-10-invwidth),
|
||||
height/2+totalHeight/2-invSize.y
|
||||
glm::min(
|
||||
viewport.x / 2 - invwidth / 2,
|
||||
viewport.x - caWidth - 10 - invwidth
|
||||
),
|
||||
viewport.y / 2 + totalHeight / 2 - invSize.y
|
||||
));
|
||||
}
|
||||
if (secondUI->getPositionFunc() == nullptr) {
|
||||
secondUI->setPos(glm::vec2(
|
||||
glm::min(
|
||||
width / 2.f - invwidth / 2.f,
|
||||
width - caWidth - (inventoryView ? 10 : 0) - invwidth
|
||||
viewport.x / 2.f - invwidth / 2.f,
|
||||
viewport.x - caWidth - (inventoryView ? 10 : 0) -
|
||||
invwidth
|
||||
),
|
||||
height / 2.f - totalHeight / 2.f
|
||||
viewport.y / 2.f - totalHeight / 2.f
|
||||
));
|
||||
}
|
||||
}
|
||||
@@ -669,7 +671,7 @@ void Hud::updateElementsPosition(const Viewport& viewport) {
|
||||
if (exchangeSlot != nullptr) {
|
||||
exchangeSlot->setPos(input.getCursor().pos);
|
||||
}
|
||||
hotbarView->setPos(glm::vec2(width/2, height-65));
|
||||
hotbarView->setPos(glm::vec2(viewport.x / 2, viewport.y - 65));
|
||||
hotbarView->setSelected(player.getChosenSlot());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user