feat(Notifications): Added push_success function (#1340)

This commit is contained in:
Rxann 2023-06-05 15:46:20 -04:00 committed by GitHub
parent 35b276e3f4
commit b8e8bccd1c
16 changed files with 36 additions and 27 deletions

View File

@ -121,7 +121,7 @@ namespace big
ents.clear(); ents.clear();
g_notification_service->push("Weapons", "Released entity."); g_notification_service->push_success("Weapons", "Released entity.");
} }
} }
} }

View File

@ -13,7 +13,7 @@ namespace big
{ {
case rage::eEventNetworkType::CEventNetworkRemovedFromSessionDueToComplaints: case rage::eEventNetworkType::CEventNetworkRemovedFromSessionDueToComplaints:
{ {
g_notification_service->push_warning("KICKED"_T.data(), "USER_DESYNC_KICKED"_T.data()); g_notification_service->push_success("KICKED"_T.data(), "USER_DESYNC_KICKED"_T.data());
break; break;
} }
case rage::eEventNetworkType::CEventNetworkEntityDamage: case rage::eEventNetworkType::CEventNetworkEntityDamage:

View File

@ -104,7 +104,7 @@ namespace big
if (plyr->block_join) if (plyr->block_join)
{ {
dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {}); dynamic_cast<player_command*>(command::get(RAGE_JOAAT("breakup")))->call(plyr, {});
g_notification_service->push("Block Join", g_notification_service->push_warning("Block Join",
std::format("Block Join method failed for {}, sending breakup kick instead...", std::format("Block Join method failed for {}, sending breakup kick instead...",
plyr->get_net_data()->m_name)); plyr->get_net_data()->m_name));
LOG(WARNING) << "Sending Breakup Kick due to block join failure... "; LOG(WARNING) << "Sending Breakup Kick due to block join failure... ";

View File

@ -37,6 +37,11 @@ namespace big
this->push({NotificationType::DANGER, title, message, std::chrono::system_clock::now(), 7000.f, 1.f}); this->push({NotificationType::DANGER, title, message, std::chrono::system_clock::now(), 7000.f, 1.f});
} }
void notification_service::push_success(std::string title, std::string message)
{
this->push({NotificationType::SUCCESS, title, message, std::chrono::system_clock::now(), 7000.f, 1.f});
}
std::vector<notification> notification_service::get() std::vector<notification> notification_service::get()
{ {
std::vector<notification> notifications_to_sent; std::vector<notification> notifications_to_sent;

View File

@ -31,6 +31,7 @@ namespace big
void push(std::string, std::string); void push(std::string, std::string);
void push_warning(std::string, std::string); void push_warning(std::string, std::string);
void push_error(std::string, std::string); void push_error(std::string, std::string);
void push_success(std::string, std::string);
std::vector<notification> get(); std::vector<notification> get();
std::map<NotificationType, ImVec4> notification_colors = { std::map<NotificationType, ImVec4> notification_colors = {

View File

@ -61,7 +61,7 @@ namespace big
{ {
write << std::setw(4) << j << std::endl; write << std::setw(4) << j << std::endl;
write.close(); write.close();
g_notification_service->push("Squad spawner", std::string("Succesfully saved ").append(s.m_name)); g_notification_service->push_success("Squad spawner", std::string("Succesfully saved ").append(s.m_name));
fetch_squads(); fetch_squads();
return true; return true;
} }

View File

@ -187,7 +187,8 @@ namespace big
4.f, 4.f,
5.f); 5.f);
//LOG(INFO) << "Navmesh probably failed, issiuing regular task "; //LOG(INFO) << "Navmesh probably failed, issiuing regular task ";
g_notification_service->push_warning("VEHICLE_CONTROLLER"_T.data(), "VEHICLE_CONTROLLER_TRY_ALT_PATHFINDING"_T.data()); g_notification_service->push_warning("VEHICLE_CONTROLLER"_T.data(),
"VEHICLE_CONTROLLER_TRY_ALT_PATHFINDING"_T.data());
script::get_current()->yield(500ms); script::get_current()->yield(500ms);
} }
@ -331,12 +332,14 @@ namespace big
if (vehicle_control::find_suitable_destination_near_player(destination, heading)) if (vehicle_control::find_suitable_destination_near_player(destination, heading))
{ {
//LOG(INFO) << "Suitable destination found"; //LOG(INFO) << "Suitable destination found";
g_notification_service->push_warning("VEHICLE_CONTROLLER"_T.data(), "VEHICLE_CONTROLLER_FOUND_LOCATION"_T.data()); g_notification_service->push_success("VEHICLE_CONTROLLER"_T.data(),
"VEHICLE_CONTROLLER_FOUND_LOCATION"_T.data());
} }
else else
{ {
//LOG(INFO) << "Couldn't find suitable destionation, defaulting to offset of player\nThis might go wrong"; //LOG(INFO) << "Couldn't find suitable destionation, defaulting to offset of player\nThis might go wrong";
g_notification_service->push_warning("VEHICLE_CONTROLLER"_T.data(), "VEHICLE_CONTROLLER_FORCE_PATHFINDING"_T.data()); g_notification_service->push_error("VEHICLE_CONTROLLER"_T.data(),
"VEHICLE_CONTROLLER_FORCE_PATHFINDING"_T.data());
destination = behind_pos; destination = behind_pos;
} }

View File

@ -27,7 +27,7 @@ namespace big::train
entity::take_control_of(train); entity::take_control_of(train);
PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), train, -1); PED::SET_PED_INTO_VEHICLE(PLAYER::PLAYER_PED_ID(), train, -1);
g_notification_service->push_error("HIJACK_TRAIN"_T.data(), "HIJACK_TRAIN_FOUND_TRAIN"_T.data()); g_notification_service->push_success("HIJACK_TRAIN"_T.data(), "HIJACK_TRAIN_FOUND_TRAIN"_T.data());
} }
} }

View File

@ -53,7 +53,6 @@ namespace big
void view::player_database() void view::player_database()
{ {
ImGui::SetNextItemWidth(300.f); ImGui::SetNextItemWidth(300.f);
components::input_text_with_hint("PLAYER"_T, "SEARCH"_T, search, sizeof(search), ImGuiInputTextFlags_None); components::input_text_with_hint("PLAYER"_T, "SEARCH"_T, search, sizeof(search), ImGuiInputTextFlags_None);
@ -95,7 +94,9 @@ namespace big
current_player->name = name_buf; current_player->name = name_buf;
} }
if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, &current_player->rockstar_id) || ImGui::Checkbox("IS_MODDER"_T.data(), &current_player->is_modder) || ImGui::Checkbox("BLOCK_JOIN"_T.data(), &current_player->block_join)) if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, &current_player->rockstar_id)
|| ImGui::Checkbox("IS_MODDER"_T.data(), &current_player->is_modder)
|| ImGui::Checkbox("BLOCK_JOIN"_T.data(), &current_player->block_join))
{ {
if (current_player->rockstar_id != selected->rockstar_id) if (current_player->rockstar_id != selected->rockstar_id)
g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player->rockstar_id); g_player_database_service->update_rockstar_id(selected->rockstar_id, current_player->rockstar_id);
@ -166,7 +167,7 @@ namespace big
g_thread_pool->push([selected] { g_thread_pool->push([selected] {
if (g_api_service->send_socialclub_message(selected->rockstar_id, message)) if (g_api_service->send_socialclub_message(selected->rockstar_id, message))
{ {
g_notification_service->push("SCAPI"_T.data(), "MSG_SENT_SUCCESS"_T.data()); g_notification_service->push_success("SCAPI"_T.data(), "MSG_SENT_SUCCESS"_T.data());
return; return;
} }
g_notification_service->push_error("SCAPI"_T.data(), "MSG_SENT_FAIL"_T.data()); g_notification_service->push_error("SCAPI"_T.data(), "MSG_SENT_FAIL"_T.data());

View File

@ -35,7 +35,7 @@ namespace big
components::button("MORS_FIX_ALL"_T, [] { components::button("MORS_FIX_ALL"_T, [] {
int amount_fixed = mobile::mors_mutual::fix_all(); int amount_fixed = mobile::mors_mutual::fix_all();
g_notification_service->push("MOBILE"_T.data(), g_notification_service->push_success("MOBILE"_T.data(),
std::vformat("VEHICLE_FIX_AMOUNT"_T, std::vformat("VEHICLE_FIX_AMOUNT"_T,
std::make_format_args(amount_fixed, std::make_format_args(amount_fixed,
amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data()))); amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data())));

View File

@ -58,7 +58,7 @@ namespace big
for (auto& item : props.items) for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " "; ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str()); ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data()); g_notification_service->push_success("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
}); });
ImGui::SameLine(); ImGui::SameLine();

View File

@ -52,7 +52,7 @@ namespace big
for (auto& item : props.items) for (auto& item : props.items)
ss << item.id << " " << item.drawable_id << " " << item.texture_id << " "; ss << item.id << " " << item.drawable_id << " " << item.texture_id << " ";
ImGui::SetClipboardText(ss.str().c_str()); ImGui::SetClipboardText(ss.str().c_str());
g_notification_service->push("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data()); g_notification_service->push_success("OUTFIT"_T.data(), "EXPORT_TO_CLIPBOARD"_T.data());
}); });
ImGui::SameLine(); ImGui::SameLine();

View File

@ -27,11 +27,10 @@ namespace big
if (components::button("Force Update Languages")) if (components::button("Force Update Languages"))
{ {
g_thread_pool->push([] g_thread_pool->push([] {
{
g_translation_service.update_language_packs(); g_translation_service.update_language_packs();
g_notification_service->push("Translations", "Finished updating translations."); g_notification_service->push_success("Translations", "Finished updating translations.");
}); });
} }
} }

View File

@ -105,7 +105,7 @@ namespace big
if (ImGui::Selectable(driving_style_names[i], g.vehicle.auto_drive_style == (AutoDriveStyle)i)) if (ImGui::Selectable(driving_style_names[i], g.vehicle.auto_drive_style == (AutoDriveStyle)i))
{ {
g.vehicle.auto_drive_style = (AutoDriveStyle)i; g.vehicle.auto_drive_style = (AutoDriveStyle)i;
g_notification_service->push_warning("AUTO_DRIVE"_T.data(), g_notification_service->push_success("AUTO_DRIVE"_T.data(),
std::vformat("DRIVING_STYLE_SET_TO"_T.data(), std::make_format_args(driving_style_names[i]))); std::vformat("DRIVING_STYLE_SET_TO"_T.data(), std::make_format_args(driving_style_names[i])));
} }

View File

@ -10,7 +10,7 @@ namespace big
{ {
components::button("MORS_FIX_ALL"_T, [] { components::button("MORS_FIX_ALL"_T, [] {
int amount_fixed = mobile::mors_mutual::fix_all(); int amount_fixed = mobile::mors_mutual::fix_all();
g_notification_service->push("MOBILE"_T.data(), g_notification_service->push_success("MOBILE"_T.data(),
std::vformat("VEHICLE_FIX_AMOUNT"_T.data(), std::vformat("VEHICLE_FIX_AMOUNT"_T.data(),
std::make_format_args(amount_fixed, std::make_format_args(amount_fixed,
amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data()))); amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data())));

View File

@ -91,7 +91,7 @@ namespace big
if (g_api_service->download_job_metadata(content_id, f1 < 0 ? 0 : f1, f0 < 0 ? 0 : f0, NETWORK::UGC_GET_CONTENT_LANGUAGE(0))) if (g_api_service->download_job_metadata(content_id, f1 < 0 ? 0 : f1, f0 < 0 ? 0 : f0, NETWORK::UGC_GET_CONTENT_LANGUAGE(0)))
{ {
cached_creator_files = false; cached_creator_files = false;
g_notification_service->push("CREATOR_JOB_IMPORT_NOTIFICATION"_T.data(), g_notification_service->push_success("CREATOR_JOB_IMPORT_NOTIFICATION"_T.data(),
"CREATOR_JOB_IMPORT_SUCCESS"_T.data()); "CREATOR_JOB_IMPORT_SUCCESS"_T.data());
} }
else else