mirror of
https://github.com/XProger/OpenLara.git
synced 2025-08-22 21:03:19 +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:
@@ -1544,10 +1544,15 @@ struct Inventory {
|
|||||||
|
|
||||||
vec2 size = vec2(180, 10);
|
vec2 size = vec2(180, 10);
|
||||||
vec2 pos;
|
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);
|
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);
|
pos = vec2(UI::width - 32 - size.x - eye, 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UI::renderBar(UI::BAR_HEALTH, pos, size, health);
|
UI::renderBar(UI::BAR_HEALTH, pos, size, health);
|
||||||
}
|
}
|
||||||
|
@@ -3118,10 +3118,13 @@ struct Lara : Character {
|
|||||||
if (p.w != 0.0f) {
|
if (p.w != 0.0f) {
|
||||||
p.x = ( p.x / p.w * 0.5f + 0.5f) * UI::width;
|
p.x = ( p.x / p.w * 0.5f + 0.5f) * UI::width;
|
||||||
p.y = (-p.y / p.w * 0.5f + 0.5f) * UI::height;
|
p.y = (-p.y / p.w * 0.5f + 0.5f) * UI::height;
|
||||||
|
if (game->getLara(1)) {
|
||||||
|
p.x *= 0.5f;
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
p = vec4(UI::width * 0.5f, UI::height * 0.5f, 0.0f, 0.0f);
|
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++;
|
saveStats.pickups++;
|
||||||
}
|
}
|
||||||
pickupListCount = 0;
|
pickupListCount = 0;
|
||||||
|
@@ -1729,6 +1729,7 @@ struct Level : IGame {
|
|||||||
if ((Input::lastState[0] == cInventory || Input::lastState[1] == cInventory) && !level.isTitle() && inventory->titleTimer < 1.0f && !inventory->active) {
|
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;
|
int playerIndex = (Input::lastState[0] == cInventory) ? 0 : 1;
|
||||||
|
|
||||||
|
if (getLara(playerIndex)) {
|
||||||
if (level.isCutsceneLevel()) { // skip cutscene level
|
if (level.isCutsceneLevel()) { // skip cutscene level
|
||||||
loadNextLevel();
|
loadNextLevel();
|
||||||
return;
|
return;
|
||||||
@@ -1739,6 +1740,7 @@ struct Level : IGame {
|
|||||||
else
|
else
|
||||||
inventory->toggle(playerIndex);
|
inventory->toggle(playerIndex);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool invActive = inventory->isActive();
|
bool invActive = inventory->isActive();
|
||||||
|
|
||||||
@@ -1769,7 +1771,9 @@ struct Level : IGame {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!inventory->isActive()) {
|
||||||
UI::update();
|
UI::update();
|
||||||
|
}
|
||||||
|
|
||||||
float volWater, volTrack;
|
float volWater, volTrack;
|
||||||
|
|
||||||
|
14
src/ui.h
14
src/ui.h
@@ -296,6 +296,7 @@ namespace UI {
|
|||||||
struct PickupItem {
|
struct PickupItem {
|
||||||
float time;
|
float time;
|
||||||
vec2 pos;
|
vec2 pos;
|
||||||
|
int playerIndex;
|
||||||
int modelIndex;
|
int modelIndex;
|
||||||
Animation *animation;
|
Animation *animation;
|
||||||
};
|
};
|
||||||
@@ -525,6 +526,11 @@ namespace UI {
|
|||||||
if (helpTipTime > 0.0f)
|
if (helpTipTime > 0.0f)
|
||||||
helpTipTime -= Core::deltaTime;
|
helpTipTime -= Core::deltaTime;
|
||||||
|
|
||||||
|
float w = UI::width;
|
||||||
|
if (game->getLara(1)) {
|
||||||
|
w *= 0.5f;
|
||||||
|
}
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (i < pickups.length) {
|
while (i < pickups.length) {
|
||||||
PickupItem &item = pickups[i];
|
PickupItem &item = pickups[i];
|
||||||
@@ -533,7 +539,7 @@ namespace UI {
|
|||||||
delete item.animation;
|
delete item.animation;
|
||||||
pickups.remove(i);
|
pickups.remove(i);
|
||||||
} else {
|
} 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);
|
item.pos = item.pos.lerp(target, Core::deltaTime * 5.0f);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@@ -626,12 +632,13 @@ namespace UI {
|
|||||||
#endif
|
#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();
|
TR::Level *level = game->getLevel();
|
||||||
|
|
||||||
PickupItem item;
|
PickupItem item;
|
||||||
item.time = PICKUP_SHOW_TIME;
|
item.time = PICKUP_SHOW_TIME;
|
||||||
item.pos = pos;
|
item.pos = pos;
|
||||||
|
item.playerIndex = playerIndex;
|
||||||
item.modelIndex = level->getModelIndex(TR::Level::convToInv(type));
|
item.modelIndex = level->getModelIndex(TR::Level::convToInv(type));
|
||||||
if (item.modelIndex <= 0)
|
if (item.modelIndex <= 0)
|
||||||
return;
|
return;
|
||||||
@@ -690,6 +697,9 @@ namespace UI {
|
|||||||
for (int i = 0; i < pickups.length; i++) {
|
for (int i = 0; i < pickups.length; i++) {
|
||||||
const PickupItem &item = pickups[i];
|
const PickupItem &item = pickups[i];
|
||||||
|
|
||||||
|
if (item.playerIndex != game->getCamera()->cameraIndex)
|
||||||
|
continue;
|
||||||
|
|
||||||
float offset = 0.0f;
|
float offset = 0.0f;
|
||||||
if (item.time < 1.0f) {
|
if (item.time < 1.0f) {
|
||||||
offset = 1.0f - item.time;
|
offset = 1.0f - item.time;
|
||||||
|
Reference in New Issue
Block a user