added dialog screen
This commit is contained in:
parent
07364460c3
commit
c153f2fe61
@ -30,6 +30,11 @@ void GameObjectManager::initialize() {
|
|||||||
|
|
||||||
initializeLoadingScreen();
|
initializeLoadingScreen();
|
||||||
|
|
||||||
|
if (!dialogTextures.empty()) { // Проверяем, есть ли диалоги
|
||||||
|
dialogTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24(dialogTextures[dialogIndex]));
|
||||||
|
isDialogActive = true;
|
||||||
|
}
|
||||||
|
|
||||||
std::function<bool()> loadingFunction1 = [this]()
|
std::function<bool()> loadingFunction1 = [this]()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -268,7 +273,14 @@ void GameObjectManager::switch_room(int index){
|
|||||||
void GameObjectManager::handleEvent(const SDL_Event& event) {
|
void GameObjectManager::handleEvent(const SDL_Event& event) {
|
||||||
// debug room switching
|
// debug room switching
|
||||||
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
if (event.type == SDL_MOUSEBUTTONDOWN && event.button.button == SDL_BUTTON_RIGHT) {
|
||||||
|
if (isDialogActive) {
|
||||||
|
dialogIndex++;
|
||||||
|
if (dialogIndex < dialogTextures.size()) {
|
||||||
|
dialogTexturePtr = std::make_shared<Texture>(CreateTextureDataFromBmp24(dialogTextures[dialogIndex]));
|
||||||
|
} else {
|
||||||
|
isDialogActive = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (event.type == SDL_MOUSEBUTTONDOWN) {
|
else if (event.type == SDL_MOUSEBUTTONDOWN) {
|
||||||
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
|
const auto highlightedObjects = rooms[current_room_index].findByHighlighted(true);
|
||||||
|
|||||||
@ -71,10 +71,6 @@ public:
|
|||||||
//ActiveObjectManager aoMgr;
|
//ActiveObjectManager aoMgr;
|
||||||
int objects_in_inventory;
|
int objects_in_inventory;
|
||||||
|
|
||||||
std::shared_ptr<Texture> dialog;
|
|
||||||
bool isDialogActive = true;
|
|
||||||
|
|
||||||
|
|
||||||
std::shared_ptr<ZL::Texture> loadingScreenTexturePtr;
|
std::shared_ptr<ZL::Texture> loadingScreenTexturePtr;
|
||||||
|
|
||||||
ZL::VertexDataStruct loadingScreenMesh;
|
ZL::VertexDataStruct loadingScreenMesh;
|
||||||
@ -91,6 +87,14 @@ public:
|
|||||||
ZL::VertexDataStruct monsterScreenMesh;
|
ZL::VertexDataStruct monsterScreenMesh;
|
||||||
ZL::VertexRenderStruct monsterScreenMeshMutable;
|
ZL::VertexRenderStruct monsterScreenMeshMutable;
|
||||||
|
|
||||||
|
std::vector<std::string> dialogTextures = { // Список диалогов
|
||||||
|
"./start_dialog.bmp",
|
||||||
|
"./next_dialog.bmp",
|
||||||
|
};
|
||||||
|
int dialogIndex = 0; // Текущий индекс диалога
|
||||||
|
std::shared_ptr<Texture> dialogTexturePtr; // Активная текстура диалога
|
||||||
|
bool isDialogActive = false; // Флаг активности диалога
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//int animationCounter = 0;
|
//int animationCounter = 0;
|
||||||
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши
|
int lastMouseX = 0; // Добавляем переменные для хранения позиции мыши
|
||||||
|
|||||||
@ -210,6 +210,18 @@ void RenderSystem::drawUI(const GameObjectManager& gameObjects) {
|
|||||||
renderer.PushMatrix();
|
renderer.PushMatrix();
|
||||||
renderer.LoadIdentity();
|
renderer.LoadIdentity();
|
||||||
|
|
||||||
|
// Отрисовка диалогового окна, если оно активно
|
||||||
|
if (gameObjects.isDialogActive && gameObjects.dialogTexturePtr) {
|
||||||
|
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{1.5f, 1.5f, 1.0f}); // Увеличиваем размер
|
||||||
|
glBindTexture(GL_TEXTURE_2D, gameObjects.dialogTexturePtr->getTexID());
|
||||||
|
renderer.DrawVertexRenderStruct(gameObjects.inventoryIconMeshMutable); // Используем 2D меш инвентаря
|
||||||
|
renderer.PopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
//for (const auto* ao : gameObjects.aoMgr.findByHighlighted(true)) {
|
//for (const auto* ao : gameObjects.aoMgr.findByHighlighted(true)) {
|
||||||
for (auto& ao : gameObjects.rooms[gameObjects.current_room_index].findByHighlighted(true)) {
|
for (auto& ao : gameObjects.rooms[gameObjects.current_room_index].findByHighlighted(true)) {
|
||||||
std::cout << ao->name << std::endl;
|
std::cout << ao->name << std::endl;
|
||||||
@ -401,8 +413,4 @@ void RenderSystem::drawObjects(GameObjectManager& gameObjects){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSystem::drawDialog(GameObjectManager& gameObjects){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace ZL
|
} // namespace ZL
|
||||||
|
|||||||
BIN
next_dialog.bmp
Normal file
BIN
next_dialog.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.7 MiB |
Loading…
Reference in New Issue
Block a user