#include "scenedialoguepanel.h" #include "features/gamefeatures.h" #include "features/qw_statemachine.h" #include "qw_globalmetadata.h" SceneDialoguePanel::SceneDialoguePanel() { metadata.pixmap_path = QWGlobalMetadata::valueBy("DialoguePanel:pixmap_path").toString(); metadata.on_hid = QRect(QPoint(QWGlobalMetadata::valueBy("DialoguePanel:on_hid:bot_left_x" ).toInt(), // x1 QWGlobalMetadata::valueBy("DialoguePanel:on_hid:bot_left_x" ).toInt()), // y1 QPoint(QWGlobalMetadata::valueBy("DialoguePanel:on_hid:top_right_x").toInt(), // x4 QWGlobalMetadata::valueBy("DialoguePanel:on_hid:top_right_y").toInt())); // y4 metadata.on_shw = QRect(QPoint(QWGlobalMetadata::valueBy("DialoguePanel:on_shw:bot_left_x" ).toInt(), // x1 QWGlobalMetadata::valueBy("DialoguePanel:on_shw:bot_left_x" ).toInt()), // y1 QPoint(QWGlobalMetadata::valueBy("DialoguePanel:on_shw:top_right_x").toInt(), // x4 QWGlobalMetadata::valueBy("DialoguePanel:on_shw:top_right_y").toInt())); // y4 /* / * 2-------4 / * | | <- * 1-------3 */ setPixmap(QPixmap(metadata.pixmap_path)); Q_ASSERT(!pix_rect.isNull()); } void SceneDialoguePanel::onClick() {} void SceneDialoguePanel::onConnect(std::unique_ptr &game_features) { game_features->ptr_text_dlg->setDialoguePanel(shared_from_this()); } void SceneDialoguePanel::onBuildingStateMachine(QWStateMachine *state_machine, std::unique_ptr &game_features) { // Establisihing animation for dialogue panel const auto &state_gameplay = state_machine->stateByKey("state_gameplay"); QState *state_dialogue = new QState; state_machine->registerState("state_dialogue", state_dialogue); connect(state_dialogue, SIGNAL(entered()), game_features->ptr_scene, SLOT(onEntryDialogue())); QSignalTransition *enter_dialogue_transition = new QSignalTransition(game_features->ptr_text_dlg, SIGNAL(onEntryDialogueTransition())); enter_dialogue_transition->setTargetState(state_dialogue); state_gameplay->addTransition(enter_dialogue_transition); QSignalTransition *leave_dialogue_transition = new QSignalTransition(game_features->ptr_text_dlg, SIGNAL(onLeaveDialogueTransition())); leave_dialogue_transition->setTargetState(state_gameplay); state_dialogue->addTransition(leave_dialogue_transition); state_gameplay->assignProperty(this, "geometry", metadata.on_hid); state_dialogue->assignProperty(this, "geometry", metadata.on_shw); state_machine->addState(state_dialogue); } //////////////////////// void SceneDialoguePanel::setPixmap(const QPixmap &pix) noexcept { pix_rect = pix; Q_ASSERT(!pix_rect.isNull()); } QPixmap SceneDialoguePanel::pixmap() const noexcept { return pix_rect; }