12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- #include "UIController.h"
- #include "Entity.h"
- UIController::UIController()
- : ReferenceCounter()
- {}
- void UIController::addDialog(UIDialog* dialog)
- {
- if (dialog->open())
- {
- activeDialogs.add(dialog);
- }
- else
- {
- dialog->release();
- }
- }
- void UIController::api(Framework::StreamReader* zRequest,
- NetworkMessage* zResponse,
- Entity* zSource)
- {
- unsigned short length;
- zRequest->lese((char*)&length, 2);
- char* id = new char[length + 1];
- zRequest->lese(id, length);
- id[length] = 0;
- char type;
- zRequest->lese(&type, 1);
- switch (type)
- {
- case 0: // element message
- {
- int entityId = zSource->getId();
- for (auto dialog = activeDialogs.begin(); dialog; dialog++)
- {
- if (dialog->getId().istGleich(id)
- && dialog->getPlayerId() == entityId)
- {
- dialog->api(zRequest, zResponse);
- }
- }
- break;
- }
- case 1: // close dialog
- {
- int entityId = zSource->getId();
- for (auto dialog = activeDialogs.begin(); dialog; dialog++)
- {
- if (dialog->getId().istGleich(id)
- && dialog->getPlayerId() == entityId)
- {
- dialog.remove();
- }
- }
- break;
- }
- }
- delete[] id;
- }
- void UIController::removePlayerDialogs(int playerId)
- {
- for (auto dialog = activeDialogs.begin(); dialog; dialog++)
- {
- if (dialog->getPlayerId() == playerId)
- {
- dialog.remove();
- }
- }
- }
|