GUI
This commit is contained in:
parent
b3d06906ff
commit
b0d5226915
7 changed files with 317 additions and 52 deletions
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
#include "NewPlacement.hpp"
|
||||
|
||||
#include "Chat.hpp"
|
||||
|
||||
#include "Graphics.hpp"
|
||||
|
|
@ -14,5 +16,36 @@ bool ChatAPI::isLogged() const {
|
|||
}
|
||||
|
||||
void ChatAPI::login(const Credentials& credentials) {
|
||||
mLogged = String::Logic::isEqualLogic(credentials.name, "111");
|
||||
}
|
||||
mLogged = String::Logic::isEqualLogic(credentials.pass, "1812") && String::Logic::isEqualLogic(credentials.name, "Igor");
|
||||
mChatsList = { "Serg", "Friends" };
|
||||
mChatHistories.put("Serg", { { "Serg", "Hello wanna some coke-cola?" }, { "Serg", "Will be in 5 mins" } });
|
||||
mChatHistories.put("Friends", { { "Artem", "Whos is that Serg?" }, { "Erog", "idunno" } });
|
||||
}
|
||||
|
||||
void ChatAPI::logout() {
|
||||
mLogged = false;
|
||||
mChatsList.removeAll();
|
||||
mChatHistories.removeAll();
|
||||
}
|
||||
|
||||
const ChatAPI::ChatsList* ChatAPI::getChatsList() const {
|
||||
return mLogged ? &mChatsList : nullptr;
|
||||
}
|
||||
|
||||
const ChatAPI::ChatHistory* ChatAPI::getChatHistory(const String& chatName) const {
|
||||
if (!mLogged) return nullptr;
|
||||
|
||||
auto history = mChatHistories.presents(chatName);
|
||||
return history ? &mChatHistories.getSlotVal(history) : nullptr;
|
||||
}
|
||||
|
||||
void ChatAPI::send(const String& chatName, const Message& message) {
|
||||
if (!mLogged) return;
|
||||
|
||||
auto iter = mChatHistories.presents(chatName);
|
||||
auto history = iter ? &mChatHistories.getSlotVal(iter) : nullptr;
|
||||
|
||||
if (!history) return;
|
||||
|
||||
history->pushBack(message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue