From 56d9d39b717991a356e78668baa73549474fcafa Mon Sep 17 00:00:00 2001 From: Rxann <80224521+Rxann@users.noreply.github.com> Date: Mon, 5 Jun 2023 15:46:20 -0400 Subject: [PATCH] feat(Notifications): Added push_success function (#1340) --- src/backend/looped/weapons/gravity_gun.cpp | 2 +- src/hooks/info/get_network_event_data.cpp | 2 +- .../player_management/assign_physical_index.cpp | 2 +- .../notifications/notification_service.cpp | 5 +++++ .../notifications/notification_service.hpp | 1 + .../squad_spawner/squad_spawner_save_files.cpp | 2 +- .../vehicle/vehicle_control_service.cpp | 9 ++++++--- src/util/train.hpp | 2 +- src/views/network/view_player_database.cpp | 17 +++++++++-------- src/views/self/view_mobile.cpp | 2 +- src/views/self/view_outfit_editor.cpp | 4 ++-- src/views/self/view_outfit_slots.cpp | 2 +- .../settings/view_translation_settings.cpp | 5 ++--- src/views/vehicle/view_fun_vehicle.cpp | 2 +- src/views/vehicle/view_vehicle.cpp | 4 ++-- src/views/world/view_creator.cpp | 2 +- 16 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/backend/looped/weapons/gravity_gun.cpp b/src/backend/looped/weapons/gravity_gun.cpp index 792f3505..2222056a 100644 --- a/src/backend/looped/weapons/gravity_gun.cpp +++ b/src/backend/looped/weapons/gravity_gun.cpp @@ -121,7 +121,7 @@ namespace big ents.clear(); - g_notification_service->push("Weapons", "Released entity."); + g_notification_service->push_success("Weapons", "Released entity."); } } } diff --git a/src/hooks/info/get_network_event_data.cpp b/src/hooks/info/get_network_event_data.cpp index 20be0350..50c8f094 100644 --- a/src/hooks/info/get_network_event_data.cpp +++ b/src/hooks/info/get_network_event_data.cpp @@ -13,7 +13,7 @@ namespace big { 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; } case rage::eEventNetworkType::CEventNetworkEntityDamage: diff --git a/src/hooks/player_management/assign_physical_index.cpp b/src/hooks/player_management/assign_physical_index.cpp index efa92502..4cd31092 100644 --- a/src/hooks/player_management/assign_physical_index.cpp +++ b/src/hooks/player_management/assign_physical_index.cpp @@ -104,7 +104,7 @@ namespace big if (plyr->block_join) { dynamic_cast(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...", plyr->get_net_data()->m_name)); LOG(WARNING) << "Sending Breakup Kick due to block join failure... "; diff --git a/src/services/notifications/notification_service.cpp b/src/services/notifications/notification_service.cpp index bca2361c..95cd05ae 100644 --- a/src/services/notifications/notification_service.cpp +++ b/src/services/notifications/notification_service.cpp @@ -37,6 +37,11 @@ namespace big 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_service::get() { std::vector notifications_to_sent; diff --git a/src/services/notifications/notification_service.hpp b/src/services/notifications/notification_service.hpp index 3c33e95e..1236f487 100644 --- a/src/services/notifications/notification_service.hpp +++ b/src/services/notifications/notification_service.hpp @@ -31,6 +31,7 @@ namespace big void push(std::string, std::string); void push_warning(std::string, std::string); void push_error(std::string, std::string); + void push_success(std::string, std::string); std::vector get(); std::map notification_colors = { diff --git a/src/services/squad_spawner/squad_spawner_save_files.cpp b/src/services/squad_spawner/squad_spawner_save_files.cpp index 18d3ed1b..8582ff61 100644 --- a/src/services/squad_spawner/squad_spawner_save_files.cpp +++ b/src/services/squad_spawner/squad_spawner_save_files.cpp @@ -61,7 +61,7 @@ namespace big { write << std::setw(4) << j << std::endl; 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(); return true; } diff --git a/src/services/vehicle/vehicle_control_service.cpp b/src/services/vehicle/vehicle_control_service.cpp index 29310145..dffbb5bd 100644 --- a/src/services/vehicle/vehicle_control_service.cpp +++ b/src/services/vehicle/vehicle_control_service.cpp @@ -187,7 +187,8 @@ namespace big 4.f, 5.f); //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); } @@ -331,12 +332,14 @@ namespace big if (vehicle_control::find_suitable_destination_near_player(destination, heading)) { //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 { //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; } diff --git a/src/util/train.hpp b/src/util/train.hpp index f0c8f79e..0e33fc6a 100644 --- a/src/util/train.hpp +++ b/src/util/train.hpp @@ -27,7 +27,7 @@ namespace big::train entity::take_control_of(train); 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()); } } diff --git a/src/views/network/view_player_database.cpp b/src/views/network/view_player_database.cpp index cf18c56e..e4064729 100644 --- a/src/views/network/view_player_database.cpp +++ b/src/views/network/view_player_database.cpp @@ -30,11 +30,11 @@ namespace big //render status circle ImGui::GetWindowDrawList()->AddCircleFilled(ImVec2(cursor_pos.x + 4.f + circle_size, cursor_pos.y + 4.f + circle_size), - circle_size, - ImColor(plyr_state == PlayerOnlineStatus::ONLINE ? ImVec4(0.f, 1.f, 0.f, 1.f) : - plyr_state == PlayerOnlineStatus::OFFLINE ? ImVec4(1.f, 0.f, 0.f, 1.f) : - plyr_state == PlayerOnlineStatus::UNKNOWN ? ImVec4(.5f, .5f, .5f, 1.0f) : - ImVec4(.5f, .5f, .5f, 1.0f))); + circle_size, + ImColor(plyr_state == PlayerOnlineStatus::ONLINE ? ImVec4(0.f, 1.f, 0.f, 1.f) : + plyr_state == PlayerOnlineStatus::OFFLINE ? ImVec4(1.f, 0.f, 0.f, 1.f) : + plyr_state == PlayerOnlineStatus::UNKNOWN ? ImVec4(.5f, .5f, .5f, 1.0f) : + ImVec4(.5f, .5f, .5f, 1.0f))); //we need some padding ImVec2 cursor = ImGui::GetCursorPos(); @@ -53,7 +53,6 @@ namespace big void view::player_database() { - ImGui::SetNextItemWidth(300.f); 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; } - if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, ¤t_player->rockstar_id) || ImGui::Checkbox("IS_MODDER"_T.data(), ¤t_player->is_modder) || ImGui::Checkbox("BLOCK_JOIN"_T.data(), ¤t_player->block_join)) + if (ImGui::InputScalar("RID"_T.data(), ImGuiDataType_S64, ¤t_player->rockstar_id) + || ImGui::Checkbox("IS_MODDER"_T.data(), ¤t_player->is_modder) + || ImGui::Checkbox("BLOCK_JOIN"_T.data(), ¤t_player->block_join)) { if (current_player->rockstar_id != selected->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] { 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; } g_notification_service->push_error("SCAPI"_T.data(), "MSG_SENT_FAIL"_T.data()); diff --git a/src/views/self/view_mobile.cpp b/src/views/self/view_mobile.cpp index 2a9dfddb..4f8839c1 100644 --- a/src/views/self/view_mobile.cpp +++ b/src/views/self/view_mobile.cpp @@ -35,7 +35,7 @@ namespace big components::button("MORS_FIX_ALL"_T, [] { 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::make_format_args(amount_fixed, amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data()))); diff --git a/src/views/self/view_outfit_editor.cpp b/src/views/self/view_outfit_editor.cpp index 1bec730b..b6f142f4 100644 --- a/src/views/self/view_outfit_editor.cpp +++ b/src/views/self/view_outfit_editor.cpp @@ -17,7 +17,7 @@ namespace big item.drawable_id = PED::GET_PED_DRAWABLE_VARIATION(self::ped, item.id); item.drawable_id_max = PED::GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(self::ped, item.id) - 1; - item.texture_id = PED::GET_PED_TEXTURE_VARIATION(self::ped, item.id); + item.texture_id = PED::GET_PED_TEXTURE_VARIATION(self::ped, item.id); item.texture_id_max = PED::GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(self::ped, item.id, item.drawable_id) - 1; } @@ -58,7 +58,7 @@ namespace big for (auto& item : props.items) ss << item.id << " " << item.drawable_id << " " << item.texture_id << " "; 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(); diff --git a/src/views/self/view_outfit_slots.cpp b/src/views/self/view_outfit_slots.cpp index 2b559935..9e82fc81 100644 --- a/src/views/self/view_outfit_slots.cpp +++ b/src/views/self/view_outfit_slots.cpp @@ -52,7 +52,7 @@ namespace big for (auto& item : props.items) ss << item.id << " " << item.drawable_id << " " << item.texture_id << " "; 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(); diff --git a/src/views/settings/view_translation_settings.cpp b/src/views/settings/view_translation_settings.cpp index 9f8da874..01c8033e 100644 --- a/src/views/settings/view_translation_settings.cpp +++ b/src/views/settings/view_translation_settings.cpp @@ -27,11 +27,10 @@ namespace big if (components::button("Force Update Languages")) { - g_thread_pool->push([] - { + g_thread_pool->push([] { g_translation_service.update_language_packs(); - g_notification_service->push("Translations", "Finished updating translations."); + g_notification_service->push_success("Translations", "Finished updating translations."); }); } } diff --git a/src/views/vehicle/view_fun_vehicle.cpp b/src/views/vehicle/view_fun_vehicle.cpp index 66de04fb..9f4f076c 100644 --- a/src/views/vehicle/view_fun_vehicle.cpp +++ b/src/views/vehicle/view_fun_vehicle.cpp @@ -105,7 +105,7 @@ namespace big if (ImGui::Selectable(driving_style_names[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]))); } diff --git a/src/views/vehicle/view_vehicle.cpp b/src/views/vehicle/view_vehicle.cpp index c25cb981..0a488cc8 100644 --- a/src/views/vehicle/view_vehicle.cpp +++ b/src/views/vehicle/view_vehicle.cpp @@ -10,7 +10,7 @@ namespace big { components::button("MORS_FIX_ALL"_T, [] { 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::make_format_args(amount_fixed, amount_fixed == 1 ? "VEHICLE_FIX_HAS"_T.data() : "VEHICLE_FIX_HAVE"_T.data()))); @@ -78,7 +78,7 @@ namespace big components::command_checkbox<"blockhoming">(); components::command_checkbox<"driveonwater">(); components::command_checkbox<"vehiclecontrol">(); - + ImGui::EndGroup(); ImGui::SameLine(); diff --git a/src/views/world/view_creator.cpp b/src/views/world/view_creator.cpp index 6ca0b862..10ceaa84 100644 --- a/src/views/world/view_creator.cpp +++ b/src/views/world/view_creator.cpp @@ -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))) { 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()); } else