not worked battery dialog windows

This commit is contained in:
maka70vv 2025-03-03 07:13:31 +06:00
parent 0e862e7a61
commit 112be9bb0c
5 changed files with 27 additions and 1 deletions

View File

@ -281,6 +281,14 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
isDialogActive = false;
}
}
if (isBatteryDialogActive) {
BatteryDialogIndex++;
if (BatteryDialogIndex < batteryDialogTextures.size()) {
batteryDialogTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24(batteryDialogTextures[BatteryDialogIndex]));
} else {
isBatteryDialogActive = false;
}
}
}
else if (event.type == SDL_MOUSEBUTTONDOWN) {
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
@ -322,12 +330,13 @@ void GameObjectManager::handleEvent(const SDL_Event& event) {
if (InventoryItem* item = GetItemSelected(true)){
std::cout << item->name << std::endl;
if (item->name == "carToy") {
std::cout << item->name << std::endl;
// Проверить, наведена ли мышь на лампу
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
std::cout << highlightedObjects.size() << std::endl;
for (auto* ao : highlightedObjects) {
if (ao && ao->name == "lampe") {
isBatteryDialogActive = true;
// Create a new lamp object with updated texture
ActiveObject updatedLamp = *ao;
// Change from dark to lit texture

View File

@ -96,6 +96,13 @@ public:
std::shared_ptr<Texture> dialogTexturePtr; // Активная текстура диалога
bool isDialogActive = false; // Флаг активности диалога
std::vector<std::string> batteryDialogTextures = { // Список диалогов
"./battery_dialog.bmp",
};
int BatteryDialogIndex = 0; // Текущий индекс диалога
std::shared_ptr<Texture> batteryDialogTexturePtr; // Активная текстура диалога
bool isBatteryDialogActive = false; // Флаг активности диалога
private:
//int animationCounter = 0;
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши

View File

@ -221,6 +221,16 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable); // Используем 2D меш инвентаря
renderer.PopMatrix();
}
if (gameObjects.isBatteryDialogActive && gameObjects.batteryDialogTexturePtr) {
renderer.PushMatrix();
float xPos = Environment::width / 2.0f - 250; // Центрируем
float yPos = Environment::height / 2.0f - 125; // Центрируем
renderer.TranslateMatrix(Vector3f{xPos, yPos, 0.0f});
renderer.ScaleMatrix(Vector3f{10.5f, 10.5f, 1.0f}); // Увеличиваем размер
glBindTexture(GL_TEXTURE_2D, gameObjects.batteryDialogTexturePtr->getTexID());
renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable); // Используем 2D меш инвентаря
renderer.PopMatrix();
}
//for (const auto* ao : gameObjects.aoMgr.findByHighlighted(true)) {
for (auto& ao : gameObjects.rooms[gameObjects.current_room_index].findByHighlighted(true)) {

BIN
battery_dialog.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.7 MiB

After

Width:  |  Height:  |  Size: 6.3 MiB