forked from Green-Sky/tomato
add auto dirty (save toxfile) + minor stuff
This commit is contained in:
parent
93e5bb867b
commit
d5e2dd2e1f
@ -10,8 +10,10 @@ add_executable(tomato
|
||||
main_screen.hpp
|
||||
main_screen.cpp
|
||||
|
||||
tox_client.hpp
|
||||
tox_client.cpp
|
||||
./tox_client.hpp
|
||||
./tox_client.cpp
|
||||
./auto_dirty.hpp
|
||||
./auto_dirty.cpp
|
||||
|
||||
theme.hpp
|
||||
texture_uploader.hpp
|
||||
|
62
src/auto_dirty.cpp
Normal file
62
src/auto_dirty.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "./auto_dirty.hpp"
|
||||
|
||||
#include "./tox_client.hpp"
|
||||
|
||||
// TODO: add more events
|
||||
|
||||
void AutoDirty::subscribe(void) {
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_SELF_CONNECTION_STATUS);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_CONNECTION_STATUS);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_FRIEND_REQUEST);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_GROUP_INVITE);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_GROUP_SELF_JOIN);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_JOIN);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_GROUP_PEER_EXIT);
|
||||
_tc.subscribe(this, Tox_Event::TOX_EVENT_CONFERENCE_INVITE);
|
||||
}
|
||||
|
||||
AutoDirty::AutoDirty(ToxClient& tc) : _tc(tc) {
|
||||
subscribe();
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Self_Connection_Status*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Friend_Connection_Status*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Friend_Request*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Group_Invite*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Group_Self_Join*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Group_Peer_Join*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Group_Peer_Exit*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool AutoDirty::onToxEvent(const Tox_Event_Conference_Invite*) {
|
||||
_tc.setDirty();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
27
src/auto_dirty.hpp
Normal file
27
src/auto_dirty.hpp
Normal file
@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include <solanaceae/toxcore/tox_event_interface.hpp>
|
||||
|
||||
// fwd
|
||||
class ToxClient;
|
||||
|
||||
// sets ToxClient dirty on some events
|
||||
class AutoDirty : public ToxEventI {
|
||||
ToxClient& _tc;
|
||||
|
||||
void subscribe(void); // private
|
||||
|
||||
public:
|
||||
AutoDirty(ToxClient& tc);
|
||||
|
||||
protected: // tox events
|
||||
bool onToxEvent(const Tox_Event_Self_Connection_Status* e) override;
|
||||
bool onToxEvent(const Tox_Event_Friend_Connection_Status* e) override;
|
||||
bool onToxEvent(const Tox_Event_Friend_Request* e) override;
|
||||
bool onToxEvent(const Tox_Event_Group_Invite* e) override;
|
||||
bool onToxEvent(const Tox_Event_Group_Self_Join* e) override;
|
||||
bool onToxEvent(const Tox_Event_Group_Peer_Join* e) override;
|
||||
bool onToxEvent(const Tox_Event_Group_Peer_Exit* e) override;
|
||||
bool onToxEvent(const Tox_Event_Conference_Invite* e) override;
|
||||
};
|
||||
|
@ -88,14 +88,16 @@ void ChatGui4::render(void) {
|
||||
if (ri.name) {
|
||||
ImGui::InputText("name to join with", &self_name);
|
||||
} else {
|
||||
ImGui::TextUnformatted("");
|
||||
//ImGui::TextUnformatted("");
|
||||
ImGui::Dummy({0, TEXT_BASE_HEIGHT});
|
||||
}
|
||||
|
||||
static std::string password;
|
||||
if (ri.password) {
|
||||
ImGui::InputText("password to join with", &password);
|
||||
} else {
|
||||
ImGui::TextUnformatted("");
|
||||
////ImGui::TextUnformatted("");
|
||||
ImGui::Dummy({0, TEXT_BASE_HEIGHT});
|
||||
}
|
||||
|
||||
if (ImGui::Button("Accept")) {
|
||||
@ -515,12 +517,11 @@ bool ChatGui4::renderContactListContactBig(const Contact3 c) {
|
||||
ImGui::SameLine();
|
||||
ImGui::BeginGroup();
|
||||
{
|
||||
ImGui::Text("%s", (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name.c_str() : "<unk>"));
|
||||
if (request_incoming) {
|
||||
ImGui::TextUnformatted("Incoming request/invite");
|
||||
} else if (request_outgoing) {
|
||||
ImGui::TextUnformatted("Outgoing request/invite");
|
||||
} else {
|
||||
ImGui::Text("%s", (_cr.all_of<Contact::Components::Name>(c) ? _cr.get<Contact::Components::Name>(c).name.c_str() : "<unk>"));
|
||||
}
|
||||
//ImGui::Text("status message...");
|
||||
//ImGui::TextDisabled("hi");
|
||||
|
@ -10,6 +10,7 @@ MainScreen::MainScreen(SDL_Renderer* renderer_, std::string save_path) :
|
||||
renderer(renderer_),
|
||||
rmm(cr),
|
||||
tc(save_path),
|
||||
ad(tc),
|
||||
tcm(cr, tc, tc),
|
||||
tmm(rmm, cr, tcm, tc, tc),
|
||||
ttm(rmm, cr, tcm, tc, tc),
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include <solanaceae/tox_messages/tox_transfer_manager.hpp>
|
||||
|
||||
#include "./tox_client.hpp"
|
||||
#include "./auto_dirty.hpp"
|
||||
|
||||
#include "./sdlrenderer_texture_uploader.hpp"
|
||||
#include "./chat_gui4.hpp"
|
||||
@ -39,6 +40,7 @@ struct MainScreen final : public Screen {
|
||||
|
||||
ToxEventLogger tel{std::cout};
|
||||
ToxClient tc;
|
||||
AutoDirty ad;
|
||||
ToxContactModel2 tcm;
|
||||
ToxMessageManager tmm;
|
||||
ToxTransferManager ttm;
|
||||
|
Loading…
Reference in New Issue
Block a user