mirror of
https://gitgud.io/BondageProjects/Bondage-College.git
synced 2026-04-28 04:19:50 +00:00
enh: friend add button
This commit is contained in:
parent
a26818a6e3
commit
16cd28312d
4 changed files with 74 additions and 26 deletions
|
|
@ -261,34 +261,11 @@
|
|||
/* #endregion */
|
||||
|
||||
/* #region BUTTONS */
|
||||
#friend-list-button-refresh {
|
||||
background-image: url("../Icons/Small/Reset.png");
|
||||
}
|
||||
|
||||
#friend-list-button-auto-refresh {
|
||||
background-image: url("../Icons/Wait.png");
|
||||
}
|
||||
|
||||
#friend-list-button-prev {
|
||||
background-image: url("../Icons/Small/Prev.png");
|
||||
}
|
||||
|
||||
#friend-list-button-next {
|
||||
background-image: url("../Icons/Small/Next.png");
|
||||
}
|
||||
|
||||
#friend-list-button-exit {
|
||||
background-image: url("../Icons/Small/Exit.png");
|
||||
}
|
||||
|
||||
#friend-list-reset-sorting {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#friend-list-reset-sorting {
|
||||
background-image: url("../Icons/Small/Remove.png");
|
||||
}
|
||||
|
||||
.button.inactive {
|
||||
background-color: var(--inactive-button-color);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ const FriendListIDs = Object.freeze({
|
|||
searchInput: 'friend-list-search-input',
|
||||
|
||||
btnAutoRefresh: 'friend-list-button-auto-refresh',
|
||||
btnAddFriend: 'friend-list-button-add-friend',
|
||||
btnRefresh: 'friend-list-button-refresh',
|
||||
btnPrev: 'friend-list-button-prev',
|
||||
btnNext: 'friend-list-button-next',
|
||||
|
|
@ -110,6 +111,7 @@ async function FriendListLoad() {
|
|||
{
|
||||
tooltip: TextGet("AutoRefresh"),
|
||||
role: "checkbox",
|
||||
image: "Icons/Wait.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -125,6 +127,22 @@ async function FriendListLoad() {
|
|||
},
|
||||
{
|
||||
tooltip: TextGet("Refresh"),
|
||||
image: "Icons/Small/Reset.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
classList: ['friend-list-button'],
|
||||
}
|
||||
}
|
||||
),
|
||||
ElementButton.Create(
|
||||
FriendListIDs.btnAddFriend,
|
||||
() => {
|
||||
FriendListAddFriends();
|
||||
},
|
||||
{
|
||||
tooltip: TextGet("AddFriends"),
|
||||
image: "Icons/Plus.png",
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -139,6 +157,7 @@ async function FriendListLoad() {
|
|||
},
|
||||
{
|
||||
tooltip: TextGet("PrevMode"),
|
||||
image: "Icons/Small/Prev.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -153,6 +172,7 @@ async function FriendListLoad() {
|
|||
},
|
||||
{
|
||||
tooltip: TextGet("NextMode"),
|
||||
image: "Icons/Small/Next.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -167,6 +187,7 @@ async function FriendListLoad() {
|
|||
},
|
||||
{
|
||||
tooltip: TextGet("Exit"),
|
||||
image: "Icons/Small/Exit.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -190,7 +211,8 @@ async function FriendListLoad() {
|
|||
},
|
||||
{
|
||||
tooltip: TextGet("ResetSorting"),
|
||||
tooltipPosition: 'right'
|
||||
tooltipPosition: 'right',
|
||||
image: "Icons/Small/Remove.png"
|
||||
},
|
||||
{
|
||||
button: {
|
||||
|
|
@ -989,6 +1011,49 @@ function FriendListDelete(MemberNumber) {
|
|||
ServerSend("AccountQuery", { Query: "OnlineFriends" });
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts for a comma-separated list of members to add.
|
||||
* @returns {void} - Nothing
|
||||
*/
|
||||
function FriendListAddFriends() {
|
||||
const input = prompt(TextGet("AddFriendsPrompt"));
|
||||
if (input === null) return;
|
||||
|
||||
const memberNumbers = new Set();
|
||||
input.split(",").forEach((entry) => {
|
||||
const match = entry.trim().match(/\d+/);
|
||||
if (!match) return;
|
||||
const memberNumber = Number.parseInt(match[0], 10);
|
||||
if (!Number.isNaN(memberNumber)) {
|
||||
memberNumbers.add(memberNumber);
|
||||
}
|
||||
});
|
||||
|
||||
if (memberNumbers.size === 0) {
|
||||
alert(TextGet("AddFriendsError"));
|
||||
return;
|
||||
};
|
||||
|
||||
const addedMembers = [];
|
||||
memberNumbers.forEach((memberNumber) => {
|
||||
if (!CommonIsNonNegativeInteger(memberNumber)) return;
|
||||
if (memberNumber === Player.MemberNumber) return;
|
||||
if (Player.FriendList.includes(memberNumber)) return;
|
||||
addedMembers.push(memberNumber);
|
||||
ChatRoomListUpdate(Player.FriendList, true, memberNumber, "FriendRequest", false);
|
||||
});
|
||||
|
||||
if (addedMembers.length > 0) {
|
||||
ServerPlayerRelationsSync();
|
||||
ServerSend("AccountQuery", { Query: "OnlineFriends" });
|
||||
}
|
||||
|
||||
alert(addedMembers.length > 0
|
||||
? TextSubstitute("AddFriendsSuccess", { $addedMembers: addedMembers.join(", ") }).join("")
|
||||
: TextGet("AddFriendsNoNewFriends")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles mode changes for friend list
|
||||
* @param {number} modeIndex - mode to change to
|
||||
|
|
|
|||
|
|
@ -27,3 +27,8 @@ TypeMale,Male-only room
|
|||
TypeMixed,Mixed male/female room
|
||||
TypeAsylum,Asylum room
|
||||
TypePrivate,Private room
|
||||
AddFriends,Add friends
|
||||
AddFriendsPrompt,Add friends (comma separated list of member numbers)
|
||||
AddFriendsError,No valid member numbers were provided.
|
||||
AddFriendsSuccess,Added friends numbers: $addedMembers.
|
||||
AddFriendsNoNewFriends,No new friends were added.
|
||||
|
|
|
|||
|
|
|
@ -5667,9 +5667,10 @@ function ChatRoomFriendMessage(SenderCharacter, data) {
|
|||
* @param {boolean} adding - If TRUE adding to the list, if FALSE removing from the list
|
||||
* @param {number} memberNumber - The member number to add/remove
|
||||
* @param {"FriendRequest"} [notification] - used to send notifications
|
||||
* @param {boolean} [sync = true] - if true, will sync the list to the server
|
||||
* @returns {void} - Nothing
|
||||
*/
|
||||
function ChatRoomListUpdate(list, adding, memberNumber, notification) {
|
||||
function ChatRoomListUpdate(list, adding, memberNumber, notification, sync = true) {
|
||||
if (memberNumber === Player.MemberNumber) return;
|
||||
if (!CommonIsNonNegativeInteger(memberNumber)) return;
|
||||
const numIdx = list.indexOf(memberNumber);
|
||||
|
|
@ -5695,7 +5696,7 @@ function ChatRoomListUpdate(list, adding, memberNumber, notification) {
|
|||
}
|
||||
}
|
||||
|
||||
ServerPlayerRelationsSync();
|
||||
if (sync) ServerPlayerRelationsSync();
|
||||
// The server will take care of pushing out updated character if the blacklist or whitelist was touched
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue