1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-22 12:53:22 +02:00

fix show inventory for non-existent player, show pickups overview in split-screen mode, positioning of health bar in the inventory depending on the player index for split-screen co-op

This commit is contained in:
XProger
2019-01-10 07:34:31 +03:00
parent 799cdb6956
commit 61488d9753
4 changed files with 41 additions and 19 deletions

View File

@@ -1544,10 +1544,15 @@ struct Inventory {
vec2 size = vec2(180, 10);
vec2 pos;
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR)
if (Core::settings.detail.stereo == Core::Settings::STEREO_VR) {
pos = vec2((UI::width - size.x) * 0.5f - eye * 4.0f, 96);
else
} else {
if (game->getLara(1) && playerIndex == 0) {
pos = vec2(32 - eye, 32);
} else {
pos = vec2(UI::width - 32 - size.x - eye, 32);
}
}
UI::renderBar(UI::BAR_HEALTH, pos, size, health);
}

View File

@@ -3118,10 +3118,13 @@ struct Lara : Character {
if (p.w != 0.0f) {
p.x = ( p.x / p.w * 0.5f + 0.5f) * UI::width;
p.y = (-p.y / p.w * 0.5f + 0.5f) * UI::height;
if (game->getLara(1)) {
p.x *= 0.5f;
}
} else
p = vec4(UI::width * 0.5f, UI::height * 0.5f, 0.0f, 0.0f);
UI::addPickup(item->getEntity().type, vec2(p.x, p.y));
UI::addPickup(item->getEntity().type, camera->cameraIndex, vec2(p.x, p.y));
saveStats.pickups++;
}
pickupListCount = 0;

View File

@@ -1729,6 +1729,7 @@ struct Level : IGame {
if ((Input::lastState[0] == cInventory || Input::lastState[1] == cInventory) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active) {
int playerIndex = (Input::lastState[0] == cInventory) ? 0 : 1;
if (getLara(playerIndex)) {
if (level.isCutsceneLevel()) { // skip cutscene level
loadNextLevel();
return;
@@ -1739,6 +1740,7 @@ struct Level : IGame {
else
inventory->toggle(playerIndex);
}
}
bool invActive = inventory->isActive();
@@ -1769,7 +1771,9 @@ struct Level : IGame {
return;
}
if (!inventory->isActive()) {
UI::update();
}
float volWater, volTrack;

View File

@@ -296,6 +296,7 @@ namespace UI {
struct PickupItem {
float time;
vec2 pos;
int playerIndex;
int modelIndex;
Animation *animation;
};
@@ -525,6 +526,11 @@ namespace UI {
if (helpTipTime > 0.0f)
helpTipTime -= Core::deltaTime;
float w = UI::width;
if (game->getLara(1)) {
w *= 0.5f;
}
int i = 0;
while (i < pickups.length) {
PickupItem &item = pickups[i];
@@ -533,7 +539,7 @@ namespace UI {
delete item.animation;
pickups.remove(i);
} else {
vec2 target = vec2(UI::width - 48.0f - Core::eye * 16.0f - (i % 4) * 96.0f, UI::height - 48.0f - (i / 4) * 96.0f);
vec2 target = vec2(w - 48.0f - Core::eye * 16.0f - (i % 4) * 96.0f, UI::height - 48.0f - (i / 4) * 96.0f);
item.pos = item.pos.lerp(target, Core::deltaTime * 5.0f);
i++;
}
@@ -626,12 +632,13 @@ namespace UI {
#endif
}
void addPickup(TR::Entity::Type type, const vec2 &pos) {
void addPickup(TR::Entity::Type type, int playerIndex, const vec2 &pos) {
TR::Level *level = game->getLevel();
PickupItem item;
item.time = PICKUP_SHOW_TIME;
item.pos = pos;
item.playerIndex = playerIndex;
item.modelIndex = level->getModelIndex(TR::Level::convToInv(type));
if (item.modelIndex <= 0)
return;
@@ -690,6 +697,9 @@ namespace UI {
for (int i = 0; i < pickups.length; i++) {
const PickupItem &item = pickups[i];
if (item.playerIndex != game->getCamera()->cameraIndex)
continue;
float offset = 0.0f;
if (item.time < 1.0f) {
offset = 1.0f - item.time;