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();
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:
{
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:

View File

@ -104,7 +104,7 @@ namespace big
if (plyr->block_join)
{
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...",
plyr->get_net_data()->m_name));
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});
}
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> notifications_to_sent;

View File

@ -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<notification> get();
std::map<NotificationType, ImVec4> notification_colors = {

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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());
}
}

View File

@ -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, &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)
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());

View File

@ -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())));

View File

@ -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();

View File

@ -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();

View File

@ -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.");
});
}
}

View File

@ -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])));
}

View File

@ -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();

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)))
{
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