Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // -------------------------------------- //
- // EVIDENCE by domino54 //
- // script version: 2.0 @2016-06-29 //
- // -------------------------------------- //
- /**
- * INSTALLATION GUIDE
- * 1. Rename file to "Chat.Script.txt".
- * 2. Place this file in folder: "(user data directory)/Media/Manialinks/Common/Chat/Chat.Script.txt".
- * 3. Restart game to apply changes.
- */
- #RequireContext CManiaplanetPlugin
- #Const ScriptName "Evidence.Script.txt"
- #Const ScriptVersion "2016-06-29"
- #Const ScriptVersionNb "2.0"
- #Include "MathLib" as ML
- #Include "TextLib" as TL
- #Include "Libs/Nadeo/Manialink.Script.txt" as Manialink
- /*
- CHANGELOG
- Additions:
- + Evidence Global Chat: text with everyone using Evidence in a single group.
- + Dynamic status: option to set dynamic status depending on what you're currently doing.
- + Heavy design tweaks.
- + Buddy Invitations tab with list of all buddy requests and option to invite players.
- + Settings tab with various options of the chat plugin.
- + Group Chat can be now secured with password defined in settings tab.
- + Some extra Group Chat formatted messages commands.
- + Notifications about incoming updates.
- Tweaks:
- ~ Extremely optimized plugin code.
- ~ Buttons on the buddies cards are now displayed only when chat is in corresponding mode.
- ~ Commands sent to other buddies now won't be shown.
- ~ Command used to leave group is now called "quit", instead "leave".
- ~ Group Chat will now find names from logins with even less than 4 specified characters.
- Removed features:
- - Server mode and players amount is no longer available to check.
- - Server name is no longer visible in Group Chat mode.
- */
- // ---------------------------------- //
- // Constants
- // ---------------------------------- //
- #Const C_ImgBase "file://Media/Manialinks/Common/Chat/"
- /// Available statuses depending on user presence Id
- #Const C_UserPresenceStatus [_("Offline"), _("Available"), _("Away"), _("Busy"), _("Available"), _("Away")]
- /// Words to avoid in context status
- #Const C_ContextAvoidInTitle ["TrackMania ", "ShootMania "]
- /// Prosences on which context status will be applied
- #Const C_ContextStatusPresences [1, 3]
- /// Available statuses depending on active context
- #Const C_ContextStatusText [
- ::EContext::MenuManiaPlanet => _("In ManiaPlanet main menu"),
- ::EContext::MenuManiaTitleMain => _("In $<%1$> main menu"),
- ::EContext::MenuCustom => _("In $<%1$> custom menu"),
- ::EContext::MenuSolo => _("In $<%1$> solo menu"),
- ::EContext::MenuLocal => _("In $<%1$> multiplayer menu"),
- ::EContext::MenuEditors => _("In $<%1$> editors menu"),
- ::EContext::MenuProfile => _("In $<%1$> profile menu"),
- ::EContext::Solo => _("Playing $<%1$> solo"),
- ::EContext::Multi => _("Playing $<%1$> multiplayer"),
- ::EContext::EditorTrack => _("Editing a map in $<%1$>"),
- ::EContext::EditorPainter => _("Painting a car in $<%1$>"),
- ::EContext::EditorMediaTracker => _("Editing a replay in $<%1$>")
- ]
- // ---------------------------------- //
- // Group Chat settings
- // ---------------------------------- //
- #Const C_GroupOfflineRemovalDelay 5000 ///< Delay before removing offline buddies upon chat startup
- /// Group Chat messages format
- #Const C_GroupFormatMessage "$FF0"
- #Const C_GroupFormatSuccess "$0F0"
- #Const C_GroupFormatInfo "$6BF"
- #Const C_GroupFormatPrivate "$F80"
- #Const C_GroupFormatError "$F00Error: "
- /// Required permissions level to perform a command
- #Const C_GroupCommandPermissionsLevels [
- "kick" => 1, "mute" => 1, "unmute" => 1, "ban" => 1, "unban" => 1, "addop" => 2, "removeop" => 2
- ]
- /// Group Chat formatted messages
- #Const C_ChatMessageCommands [
- "hi" => "Hello", "bb" => "Bye", "re" => "Returned", "wb" => "Welcome back",
- "afk" => "Away from keyboard", "gtg" => "Got to go", "brb" => "Be right back",
- "gg" => "Good game", "gga" => "Good game all", "gj" => "Good job",
- "n1" => "Nice one", "ns" => "Nice shoot", "nt" => "Nice time", "ty" => "Thank you",
- "gl" => "Good luck", "hf" => "Have fun", "glhf" => "Goold luck and have fun",
- "wp" => "Well played", "ggwp" => "Good game, well played",
- "gr8" => "Great", "w8" => "Wait", "lol" => "Loo0ool", "lool" => "Looo00oool",
- "54" => "I <3 Domino", "gu" => "Guerried", "grt" => "Guerritos",
- "flo" => "Florenziusted", "nu" => "Nurpsen", "owz" => "Owzom", "wow" => "WOOW"
- ]
- /// Group Chat formatted messages, that can be used with login
- #Const C_ChatMessageWithLogin [
- "hi", "bb", "wb", "flo", "gg", "gj", "n1", "ns", "nt", "ty", "lol", "lool",
- "gl", "hf", "glhf", "wp", "ggwp", "gu", "gr8", "w8", "owz", "wow"
- ]
- // ---------------------------------- //
- /** Commands help description
- * [required parameter] <optional parameter>
- */
- #Const C_GroupCommandsHelp [
- "help" => "You seem to be really desperate.",
- "join" => "/join - Join the Group Chat server.",
- "quit" => "/quit - Leave the Group Chat server.",
- "list" => "/list <op|mute|ban|nf|logins> - Display list with logins of specified users on the server.",
- "me" => "/me [message] - Describe what are you currently doing.",
- "kick" => "/kick [login] - Disconnect specified user from the server.",
- "mute" => "/mute [login] - Mute specified user. Messages of muted users aren't shown.",
- "unmute" => "/unmute [login] - Remove mute penalty from specified user.",
- "ban" => "/ban [login] - Ban specified user from the Group Chat.",
- "unban" => "/unmute [login] - Remove ban penalty from specified user.",
- "addop" => "/addop [login] - Give specified user operator rights.",
- "removeop" => "/removeop [login] - Remove operator rights from specified user.",
- "noformat" => "/noformat <0|1> - Remove formatting from nicknames to save messages length.",
- "pm" => "/pm [login] [message] - Send private message to a specified user.",
- "pmr" => "/pmr [message] - Reply to the latest received private message.",
- "core" => "/core - Returns name and version of the Group Chat script file.",
- "rq" => "/rq - Leave the Group Chat server. With anger.",
- "bm" => "/bm - Kick yourself from the Group Chat, if you really want.",
- "/chatmsg" => "<login> - Shortcut displaying formatted message in chat."
- ]
- // ---------------------------------- //
- // Global Chat settings
- // ---------------------------------- //
- #Const C_GlobalChatServerURL "http://2.3.49.155/JavaWeb/"
- #Const C_GlobalChatServerMethods ["GET_UID", "GET_USER_LIST", "GET_MSG", "REFRESH", "SET_STATUS", "SEND_MSG"]
- #Const C_GlobalChatGetUIDTimeout 10000
- #Const C_GlobalChatRequestInterval [
- "GET_UID" => 2000,
- "GET_USER_LIST" => 7500,
- "GET_MSG" => 1000,
- "REFRESH" => 5000,
- "SET_STATUS" => 7500
- ]
- // ---------------------------------- //
- // Global variables
- // ---------------------------------- //
- declare Integer[] G_GlobalChat_ReceivedMessages; ///< Messages Ids received in Global Chat mode
- declare Boolean G_GlobalChat_ConnectionError; ///< True, if local user is not present in users list
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- ***Main***
- ***
- // ---------------------------------- //
- // Connect to the ManiaPlanet Chat server
- BuddiesManager.DesiredConnectionStatus = CBuddiesManager::EDesiredConnectionStatus::Offline;
- wait(BuddiesManager.CurrentConnectionStatus == CBuddiesManager::EConnectionStatus::Offline);
- BuddiesManager.DesiredConnectionStatus = CBuddiesManager::EDesiredConnectionStatus::Online;
- wait(BuddiesManager.CurrentConnectionStatus == CBuddiesManager::EConnectionStatus::Online);
- // ---------------------------------- //
- // Layer of the plugin icon
- declare IconLayer <=> UILayerCreate();
- IconLayer.AttachId = "IconLayer";
- IconLayer.ManialinkPage = CreateManialinkPluginIcon();
- IconLayer.Type = CUILayer::EUILayerType::ManiaplanetPlugin;
- declare IconPage <=> IconLayer.LocalPage;
- // ---------------------------------- //
- // Layer of the Evidence window
- declare WindowLayer <=> UILayerCreate();
- WindowLayer.AttachId = "WindowLayer";
- WindowLayer.ManialinkPage = CreateManialinkWindow();
- WindowLayer.Type = CUILayer::EUILayerType::Normal;
- declare WindowPage <=> WindowLayer.LocalPage;
- // ---------------------------------- //
- // Layer of the dialog box
- declare DialogLayer <=> UILayerCreate();
- DialogLayer.AttachId = "DialogBox";
- DialogLayer.ManialinkPage = CreateManialinkDialogBox();
- DialogLayer.Type = CUILayer::EUILayerType::Normal;
- declare DialogPage <=> DialogLayer.LocalPage;
- // ---------------------------------- //
- // Layer of the notices
- declare NoticesLayer <=> UILayerCreate();
- NoticesLayer.AttachId = "Notices";
- NoticesLayer.ManialinkPage = CreateManialinkNotifications();
- NoticesLayer.Type = CUILayer::EUILayerType::Normal;
- declare NoticesPage <=> NoticesLayer.LocalPage;
- // ---------------------------------- //
- // Persistent settings
- declare persistent Text[] Persistent_Evidence_BuddiesInGroup;
- declare persistent Text[] Persistent_Evidence_MutedGroupBuddies;
- // ---------------------------------- //
- // Manialink script communication
- declare NewReceivedMessages for WindowPage = Text[][]; ///< New messages to proceed
- declare ChatWidgetIsOpen for WindowPage = False; ///< Current chat state
- declare CurrentWidgetMode for WindowPage = ""; ///< Active widget mode
- declare SelectedConversation for WindowPage = ""; ///< Login of selected buddy for private conversation
- declare LegacyMailsAmount for WindowPage = 0; ///< Amount of messages in classic mailbox
- declare CurrentPluginPresenceId for WindowPage = 4; ///< Current presence Id of the user
- declare CurrentPluginStatusText for WindowPage = ""; ///< Currently displayed status of the user
- declare ManialinkTargetPresence for WindowPage = 4; ///< Requested user presence Id
- declare ManialinkCustomStatus for WindowPage = ""; ///< Custom status specified by user
- declare TotalNbUnreadMessages for WindowPage = 0; ///< Total amount of unread messages
- declare FlashTaskbar for WindowPage = False; ///< Force game to blink taskbar icon
- declare UseDynamicStatus for WindowPage = False; ///< User context status setting
- declare NoticeOnConnection for WindowPage = False; ///< Send notice on new connection
- declare UsersThatSeenMessage for WindowPage = Text[]; ///< Users that just seen message
- declare PluginNbUsersOnline for IconPage = 0; ///< Amount of buddies online
- declare PluginNbUnreadMessages for IconPage = 0; ///< Amount of unread messages from buddies and group
- declare PluginIsChatWindowOpen for IconPage = False; ///< Current chat visibility status
- declare PluginTriggerOpenChat for IconPage = False; ///< Trigger chat visibility
- declare PrevManialinkTargetPresence = 4;
- declare PrevManialinkCustomStatus = "";
- declare PrevUseDynamicStatus = False;
- declare PrevNbBuddiesInGroup = -1;
- // ---------------------------------- //
- // Plugin buddies data
- declare Text[] BuddiesList_Online for WindowPage; ///< Buddies currently being connected
- declare Text[] BuddiesList_Offline for WindowPage; ///< Buddies currently being offline
- declare Text[] BuddiesList_RequestFrom for WindowPage; ///< Incoming buddies invitations
- declare Text[] BuddiesList_RequestTo for WindowPage; ///< Sent buddies invitations
- declare Text[] BuddiesList_OnServer for WindowPage; ///< Players on current server
- declare Text[] BuddiesList_InGroup for WindowPage; ///< Buddies in the group
- declare Text[] BuddiesList_GlobalList for WindowPage; ///< Buddies available on the global chat
- declare Text[] BuddiesList_MutedUsers for WindowPage; ///< Buddies muted from the group
- declare Text[] BuddiesList_Evidence for WindowPage; ///< Buddies using Evidence chat
- declare Text[Text] BuddiesName for WindowPage; ///< Names of the buddies
- declare Integer[Text] BuddiesPresenceId for WindowPage; ///< Presence Ids of the buddies
- declare Text[Text] BuddiesStatus for WindowPage; ///< Statuses of the buddies
- declare Text[Text] BuddiesServerLogin for WindowPage; ///< Login of the servers buddies are on
- declare Boolean[Text] BuddiesIsMuted for WindowPage; ///< True if buddy is muted in Group Chat
- declare Text[Text] BuddiesJoinLink for WindowPage; ///< Links to join buddies servers
- declare Text[Text] ServersName for WindowPage; ///< Names of the buddies servers
- /// Update variables
- declare PrevNbBuddiesOffline = 0;
- declare PrevNbBuddiesRequestFrom = 0;
- declare PrevNbBuddiesRequestTo = 0;
- declare PrevNbBuddiesOnServer = 0;
- declare PrevNbBuddiesMuted = 0;
- // ---------------------------------- //
- // Dialog box layer data
- declare DialogVisible for DialogPage = False; ///< Visibility of the dialog box
- declare DialogBuddyLogin for DialogPage = ""; ///< Login of the buddy to remove
- declare DialogBuddyName for DialogPage = ""; ///< Name of the buddy to remove
- // ---------------------------------- //
- // Notifications
- declare Text[][] NewNotifications for NoticesPage; ///< New notifications to display
- declare Boolean ToolbarActive for NoticesPage; ///< ManiaPlanet toolbar visibility
- // ---------------------------------- //
- // Variables
- declare StartTime = Now;
- declare SET_STATUS = True;
- declare Text ContextAutoStatus;
- /// Update variables
- declare PrevUserServerLogin = "";
- declare PrevUserServerName = "";
- declare PrevOutgoingBuddyNames = Text[Text];
- declare ::EContext PrevActiveContext;
- ***
- // ---------------------------------- //
- // Yield
- // ---------------------------------- //
- ***Yield***
- ***
- // ---------------------------------- //
- // Buddies manager events management
- foreach (Event in BuddiesManager.PendingEvents) {
- // ---------------------------------- //
- // User received a new message
- if (Event.Type == CBuddiesEvent::EType::Message && Event.MessageBody != "") {
- // ---------------------------------- //
- // Normal message
- if (Event.MessageType != "data") {
- declare EventIsCommand = (TL::SubString(Event.MessageBody, 0, 1) == "/");
- // ---------------------------------- //
- // New message
- if (!EventIsCommand) {
- // ---------------------------------- //
- // Display and notify user about new message
- if (!Persistent_Evidence_BuddiesInGroup.exists(Event.Sender.Login))
- NewReceivedMessages.add([Event.Sender.Login, Event.Sender.Login, Event.MessageBody]);
- // ---------------------------------- //
- // Send message to all other buddies in the group
- else if (!Persistent_Evidence_MutedGroupBuddies.exists(Event.Sender.Login))
- SendMessageToGroup(Event.Sender.Login, Event.MessageBody);
- // ---------------------------------- //
- // Buddy is muted in the group
- else BuddiesManager.SendMessage(Event.Sender, "", C_GroupFormatError^"You're muted in this group!");
- }
- // ---------------------------------- //
- // New command
- else if (TL::Length(Event.MessageBody) > 1) PerformChatCommand(Event.Sender.Login, Event.MessageBody);
- // ---------------------------------- //
- // Add Evidence user
- if (Event.MessageType == "Evidence" && !BuddiesList_Evidence.exists(Event.Sender.Login))
- BuddiesList_Evidence.add(Event.Sender.Login);
- }
- // ---------------------------------- //
- // Custom data protocol
- else {
- // ---------------------------------- //
- // Buddy confirmed reading the message
- if (Event.MessageBody == "seenmessage") {
- if (!UsersThatSeenMessage.exists(Event.Sender.Login)) UsersThatSeenMessage.add(Event.Sender.Login);
- }
- }
- }
- // ---------------------------------- //
- // Buddy changed his presence
- else if (Event.Type == CBuddiesEvent::EType::PresenceChange) {
- BuddiesPresenceId[Event.Buddy.Login] = GetPresenceId(Event.Buddy.PresenceShow);
- // Update name
- BuddiesName[Event.Buddy.Login] = Event.Buddy.Name;
- // Update status
- declare BuddyStatus = Event.Buddy.PresenceStatus;
- if (BuddyStatus == "") BuddyStatus = C_UserPresenceStatus[GetPresenceId(Event.Buddy.PresenceShow)];
- BuddiesStatus[Event.Buddy.Login] = BuddyStatus;
- if (
- (BuddiesPresenceId[Event.Buddy.Login] == 4 || BuddiesPresenceId[Event.Buddy.Login] == 5) &&
- !BuddiesList_Evidence.exists(Event.Buddy.Login)
- )
- BuddiesList_Evidence.add(Event.Buddy.Login);
- // Update buddy server login
- BuddiesServerLogin[Event.Buddy.Login] = Event.Buddy.CurrentServerLogin;
- // Update buddy join link
- BuddiesJoinLink[Event.Buddy.Login] = "";
- if (Event.Buddy.CurrentServerJoinLink != "")
- BuddiesJoinLink[Event.Buddy.Login] = TL::Replace(Event.Buddy.CurrentServerJoinLink, "maniaplanet://", "");
- // Update server information
- if (Event.Buddy.CurrentServerLogin != "")
- ServersName[Event.Buddy.CurrentServerLogin] = Event.Buddy.CurrentServerName;
- // Connection notification
- if (NoticeOnConnection && !Event.PreviousIsOnline && Event.Buddy.IsOnline && Now > StartTime + C_GroupOfflineRemovalDelay)
- NewNotifications.add([_("New connection"), TL::Compose(_("%1 $zis now connected."), Event.Buddy.Name), "Icons64x64_1|Buddy"]);
- }
- // ---------------------------------- //
- // Result of the add buddy request
- else if (Event.Type == CBuddiesEvent::EType::AddBuddyResult) {
- }
- // ---------------------------------- //
- // Result of the remove buddy request
- else if (Event.Type == CBuddiesEvent::EType::RemoveBuddyResult) {
- }
- }
- // ---------------------------------- //
- // Manage events
- foreach (Event in PendingEvents) {
- // ---------------------------------- //
- // Manialink layer custom event
- if (Event.Type == CManiaplanetPluginEvent::EType::LayerCustomEvent) {
- // ---------------------------------- //
- // Send message to selected buddies
- if (Event.CustomEventType == "SendMessage" && Event.CustomEventData.count >= 2) {
- declare ConversationLogin = Event.CustomEventData[0];
- declare MessageBody = Event.CustomEventData[1];
- switch (ConversationLogin) {
- // ---------------------------------- //
- // Send message to the group
- case "*group*" : {
- declare EventIsCommand = (TL::SubString(MessageBody, 0, 1) == "/");
- if (EventIsCommand) PerformChatCommand(LocalUser.Login, MessageBody);
- else SendMessageToGroup(LocalUser.Login, MessageBody);
- }
- // ---------------------------------- //
- // Send message to global chat
- case "*global*" : {
- if (Persistent_Evidence_GlobalChatUID > 0) {
- // Destroy ongoing request and start new
- if (GlobalChat_Requests["SEND_MSG"] != Null) {
- Http.Destroy(GlobalChat_Requests["SEND_MSG"]);
- GlobalChat_Requests["SEND_MSG"] = Null;
- }
- // Start new request
- if (GlobalChat_Requests["SEND_MSG"] == Null) {
- GlobalChat_Requests["SEND_MSG"] = Http.CreateGet(FormatURL(
- C_GlobalChatServerURL,
- ["act" => "SEND_MSG",
- "uid" => TL::ToText(Persistent_Evidence_GlobalChatUID),
- "login" => LocalUser.Login, "body" => MessageBody]
- ), False);
- }
- }
- }
- // ---------------------------------- //
- // Send message to selected buddy
- default : SendMessage(ConversationLogin, "Evidence", MessageBody);
- }
- }
- // ---------------------------------- //
- // Tell the receipent user has seen their message
- else if (Event.CustomEventType == "SeenMessage" && Event.CustomEventData.count >= 1) {
- if (!BuddiesList_Evidence.exists(Event.CustomEventData[0])) continue;
- SendMessage(Event.CustomEventData[0], "data", "seenmessage");
- }
- // ---------------------------------- //
- // Copy message content to clipboard
- else if (Event.CustomEventType == "SetClipboard") {
- declare ClipboardContent = Event.CustomEventData[0];
- if (ClipboardContent != "") ClipboardSet(ClipboardContent);
- }
- // ---------------------------------- //
- // Send buddy request to a player
- else if (Event.CustomEventType == "AddBuddy") {
- BuddiesManager.AddBuddy(Event.CustomEventData[0]);
- }
- // ---------------------------------- //
- // Accept buddy request
- else if (Event.CustomEventType == "BuddyAccept") {
- declare Login = Event.CustomEventData[0];
- if (Login != "") {
- declare Buddy = BuddiesManager.GetBuddyFromLogin(Login);
- if (Buddy != Null) BuddiesManager.AcceptBuddy(Buddy);
- }
- }
- // ---------------------------------- //
- // Deny / cancel buddy request
- else if (Event.CustomEventType == "BuddyDeny") {
- declare Login = Event.CustomEventData[0];
- if (Login != "") {
- declare Buddy = BuddiesManager.GetBuddyFromLogin(Login);
- if (Buddy != Null) BuddiesManager.RemoveBuddy(Buddy);
- }
- }
- // ---------------------------------- //
- // Remove buddy
- else if (Event.CustomEventType == "RemoveBuddy") {
- DialogVisible = True;
- DialogBuddyLogin = Event.CustomEventData[0];
- if (BuddiesName.existskey(DialogBuddyLogin))
- DialogBuddyName = BuddiesName[DialogBuddyLogin];
- }
- // ---------------------------------- //
- // Confirm buddy removal
- else if (Event.CustomEventType == "BuddyRemoved") {
- if (Event.CustomEventData.existskey(0) && Event.CustomEventData[0] != "") {
- declare Login = Event.CustomEventData[0];
- declare Buddy = BuddiesManager.GetBuddyFromLogin(Login);
- if (Buddy != Null) BuddiesManager.RemoveBuddy(Buddy);
- }
- }
- // ---------------------------------- //
- // Show message notification
- else if (Event.CustomEventType == "ShowMessageNotice") {
- declare Login = Event.CustomEventData[0];
- declare Message = Event.CustomEventData[1];
- NewNotifications.add([GetNameFromLogin(Login), Message, "BgRaceScore2|Speaking"]);
- }
- }
- }
- // ---------------------------------- //
- // Update buddies amount
- // ---------------------------------- //
- // ---------------------------------- //
- // Online buddies amount change
- if (PluginNbUsersOnline != BuddiesManager.OnlineBuddies.count) {
- PluginNbUsersOnline = BuddiesManager.OnlineBuddies.count;
- BuddiesList_Online.clear();
- foreach (Buddy in BuddiesManager.OnlineBuddies) {
- BuddiesList_Online.add(Buddy.Login);
- BuddiesName[Buddy.Login] = Buddy.Name;
- }
- BuddiesList_Online = BuddiesList_Online.sort();
- }
- // ---------------------------------- //
- // Offline buddies amount change
- if (PrevNbBuddiesOffline != BuddiesManager.OfflineBuddies.count) {
- PrevNbBuddiesOffline = BuddiesManager.OfflineBuddies.count;
- BuddiesList_Offline.clear();
- foreach (Buddy in BuddiesManager.OfflineBuddies) {
- BuddiesList_Offline.add(Buddy.Login);
- BuddiesName[Buddy.Login] = Buddy.Name;
- }
- BuddiesList_Offline = BuddiesList_Offline.sort();
- }
- // ---------------------------------- //
- // Incoming buddy requests amount change
- if (PrevNbBuddiesRequestFrom != BuddiesManager.IncomingBuddyRequests.count) {
- PrevNbBuddiesRequestFrom = BuddiesManager.IncomingBuddyRequests.count;
- BuddiesList_RequestFrom.clear();
- foreach (Buddy in BuddiesManager.IncomingBuddyRequests) {
- BuddiesList_RequestFrom.add(Buddy.Login);
- BuddiesName[Buddy.Login] = Buddy.Name;
- }
- BuddiesList_RequestFrom = BuddiesList_RequestFrom.sort();
- }
- // ---------------------------------- //
- // Outgoing buddy requests amount change
- if (PrevNbBuddiesRequestTo != BuddiesManager.OutgoingBuddyRequests.count) {
- PrevNbBuddiesRequestTo = BuddiesManager.OutgoingBuddyRequests.count;
- BuddiesList_RequestTo.clear();
- foreach (Buddy in BuddiesManager.OutgoingBuddyRequests) {
- BuddiesList_RequestTo.add(Buddy.Login);
- BuddiesName[Buddy.Login] = Buddy.Name;
- }
- BuddiesList_RequestTo = BuddiesList_RequestTo.sort();
- }
- // ---------------------------------- //
- // Current server players amount change
- if (PrevNbBuddiesOnServer != CurrentServerPlayers.count) {
- PrevNbBuddiesOnServer = CurrentServerPlayers.count;
- BuddiesList_OnServer.clear();
- foreach (Player in CurrentServerPlayers) {
- BuddiesList_OnServer.add(Player.Login);
- BuddiesName[Player.Login] = Player.Name;
- }
- BuddiesList_OnServer = BuddiesList_OnServer.sort();
- }
- // ---------------------------------- //
- // Group buddies amount change
- if (PrevNbBuddiesInGroup != Persistent_Evidence_BuddiesInGroup.count) {
- PrevNbBuddiesInGroup = Persistent_Evidence_BuddiesInGroup.count;
- BuddiesList_InGroup.clear();
- foreach (Login in Persistent_Evidence_BuddiesInGroup) BuddiesList_InGroup.add(Login);
- BuddiesList_InGroup = BuddiesList_InGroup.sort();
- }
- // ---------------------------------- //
- // Muted buddies amount change
- if (PrevNbBuddiesMuted != Persistent_Evidence_MutedGroupBuddies.count) {
- PrevNbBuddiesMuted = Persistent_Evidence_MutedGroupBuddies.count;
- BuddiesList_MutedUsers.clear();
- foreach (Login in Persistent_Evidence_MutedGroupBuddies) BuddiesList_MutedUsers.add(Login);
- BuddiesList_MutedUsers = BuddiesList_MutedUsers.sort();
- }
- // ---------------------------------- //
- // Remove offline buddies from group
- if (Now > StartTime + C_GroupOfflineRemovalDelay) {
- foreach (Buddy in BuddiesManager.OfflineBuddies) {
- if (Persistent_Evidence_BuddiesInGroup.exists(Buddy.Login))
- PerformChatCommand(Buddy.Login, "/quit");
- }
- }
- // ---------------------------------- //
- // Check if name of invited buddy changed
- foreach (Buddy in BuddiesManager.OutgoingBuddyRequests) {
- if (!PrevOutgoingBuddyNames.existskey(Buddy.Login) || PrevOutgoingBuddyNames[Buddy.Login] != Buddy.Name) {
- PrevOutgoingBuddyNames[Buddy.Login] = Buddy.Name;
- BuddiesName[Buddy.Login] = Buddy.Name;
- }
- }
- // ---------------------------------- //
- // User changed his presence
- if (PrevManialinkTargetPresence != ManialinkTargetPresence) {
- PrevManialinkTargetPresence = ManialinkTargetPresence;
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // User changed his custom status
- if (PrevManialinkCustomStatus != ManialinkCustomStatus) {
- PrevManialinkCustomStatus = ManialinkCustomStatus;
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // User changed his server
- if (PrevUserServerLogin != CurrentServerLogin) {
- PrevUserServerLogin = CurrentServerLogin;
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // Server the user is playing on changed name
- if (PrevUserServerName != CurrentServerName) {
- PrevUserServerName = CurrentServerName;
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // Dynamic status usage change
- if (PrevUseDynamicStatus != UseDynamicStatus) {
- PrevUseDynamicStatus = UseDynamicStatus;
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // Status depending on active context
- if (UseDynamicStatus && PrevActiveContext != ActiveContext) {
- PrevActiveContext = ActiveContext;
- // Get status for current context
- if (C_ContextStatusText.existskey(ActiveContext)) {
- ContextAutoStatus = C_ContextStatusText[ActiveContext];
- // Compose current title pack name
- if (LoadedTitle != Null && TL::Find("%1", ContextAutoStatus, False, False)) {
- declare TitlePackName = LoadedTitle.Name;
- foreach (Word in C_ContextAvoidInTitle)
- if (TL::Find(Word, TitlePackName, False, False))
- TitlePackName = TL::Replace(TitlePackName, Word, "");
- ContextAutoStatus = TL::Compose(ContextAutoStatus, TitlePackName);
- }
- }
- // There is no available status
- else ContextAutoStatus = "";
- // Force update status
- if (UseDynamicStatus && C_ContextStatusPresences.exists(CurrentPluginPresenceId))
- SET_STATUS = True;
- }
- // ---------------------------------- //
- // Update user status and presence
- if (SET_STATUS) {
- SET_STATUS = False;
- // Get presence
- CurrentPluginPresenceId = ManialinkTargetPresence;
- // Get status
- declare NewStatusText = _("Available");
- if (ManialinkCustomStatus != "") NewStatusText = ManialinkCustomStatus;
- else if (UseDynamicStatus && ContextAutoStatus != "" && C_ContextStatusPresences.exists(CurrentPluginPresenceId))
- NewStatusText = ContextAutoStatus;
- else if (C_UserPresenceStatus.existskey(CurrentPluginPresenceId))
- NewStatusText = C_UserPresenceStatus[CurrentPluginPresenceId];
- // Send new presence and status to buddies
- BuddiesManager.ChangePresence(GetPresenceFromId(CurrentPluginPresenceId), NewStatusText);
- // Send new status to manialink
- if (CurrentServerName != "") CurrentPluginStatusText = CurrentServerName;
- else if (CurrentServerLogin != "") CurrentPluginStatusText = CurrentServerLogin;
- else CurrentPluginStatusText = NewStatusText;
- }
- // ---------------------------------- //
- // User changed chat visibility through plugin icon
- if (PluginTriggerOpenChat) {
- PluginTriggerOpenChat = False;
- ChatWidgetIsOpen = !ChatWidgetIsOpen;
- }
- // ---------------------------------- //
- // Other
- ToolBarForceShow = ChatWidgetIsOpen;
- PluginIsChatWindowOpen = ChatWidgetIsOpen;
- LegacyMailsAmount = Messenger_MessagesCount;
- PluginNbUnreadMessages = TotalNbUnreadMessages;
- ToolbarActive = ToolBarIsActive;
- if (FlashTaskbar) {
- FlashTaskbar = False;
- FlashWindow();
- }
- ***
- // ---------------------------------- //
- // Global Chat start
- // ---------------------------------- //
- ***GlobalChatStart***
- ***
- // ---------------------------------- //
- // Persistent settings
- declare persistent Integer Persistent_Evidence_GlobalChatUID = -1;
- Persistent_Evidence_GlobalChatUID = -1;
- // ---------------------------------- //
- // Manialink communication
- declare GlobalChat_ConnectionStatus for WindowPage = 0;
- declare EnableGlobalChat for WindowPage = False;
- // ---------------------------------- //
- // Variables
- declare CHttpRequest[Text] GlobalChat_Requests;
- declare Integer[Text] GlobalChat_RequestStartTime;
- declare Integer[Text] GlobalChat_NextRequestTime;
- /// Init requests
- foreach (Method in C_GlobalChatServerMethods) {
- GlobalChat_Requests[Method] = Null;
- GlobalChat_RequestStartTime[Method] = 0;
- GlobalChat_NextRequestTime[Method] = 0;
- }
- ***
- // ---------------------------------- //
- // Global Chat yield
- // ---------------------------------- //
- ***GlobalChatYield***
- ***
- // ---------------------------------- //
- // Global Chat is turned off
- if (!EnableGlobalChat) {
- if (GlobalChat_ConnectionStatus != 0) {
- GlobalChat_ConnectionStatus = 0;
- Persistent_Evidence_GlobalChatUID = -1;
- declare XMLDocument = Xml.Create("<users/>");
- LoadUsersData(XMLDocument);
- Xml.Destroy(XMLDocument);
- }
- }
- // ---------------------------------- //
- // Get new UID from server
- else if (Persistent_Evidence_GlobalChatUID <= 0) {
- GlobalChat_ConnectionStatus = 3;
- // Start new request
- if (GlobalChat_Requests["GET_UID"] == Null) {
- // Prevent spamming the server
- if (Now >= GlobalChat_NextRequestTime["GET_UID"]) {
- GlobalChat_Requests["GET_UID"] = Http.CreateGet(FormatURL(C_GlobalChatServerURL, [
- "act" => "GET_UID",
- "login" => LocalUser.Login
- ]), False);
- GlobalChat_RequestStartTime["GET_UID"] = Now;
- GlobalChat_NextRequestTime["GET_UID"] = Now + C_GlobalChatRequestInterval["GET_UID"];
- }
- }
- // Set new UID
- else if (GlobalChat_Requests["GET_UID"].IsCompleted) {
- Persistent_Evidence_GlobalChatUID = TL::ToInteger(GlobalChat_Requests["GET_UID"].Result);
- Http.Destroy(GlobalChat_Requests["GET_UID"]);
- GlobalChat_Requests["GET_UID"] = Null;
- }
- // Destroy timed out request
- else if (Now >= GlobalChat_RequestStartTime["GET_UID"] + C_GlobalChatGetUIDTimeout) {
- Http.Destroy(GlobalChat_Requests["GET_UID"]);
- GlobalChat_Requests["GET_UID"] = Null;
- }
- }
- // ---------------------------------- //
- // Perform all important requests
- else {
- GlobalChat_ConnectionStatus = 1;
- // ---------------------------------- //
- // Trigger chat error
- if (G_GlobalChat_ConnectionError) {
- G_GlobalChat_ConnectionError = False;
- Persistent_Evidence_GlobalChatUID = -1;
- }
- // ---------------------------------- //
- // Update connection time
- if (Now > GlobalChat_NextRequestTime["REFRESH"]) {
- // Destroy ongoing request and start new
- if (GlobalChat_Requests["REFRESH"] != Null) {
- Http.Destroy(GlobalChat_Requests["REFRESH"]);
- GlobalChat_Requests["REFRESH"] = Null;
- }
- // Start new request
- if (GlobalChat_Requests["REFRESH"] == Null) {
- GlobalChat_Requests["REFRESH"] = Http.CreateGet(FormatURL(C_GlobalChatServerURL, [
- "act" => "REFRESH",
- "uid" => TL::ToText(Persistent_Evidence_GlobalChatUID),
- "login" => LocalUser.Login
- ]), False);
- GlobalChat_NextRequestTime["REFRESH"] = Now + C_GlobalChatRequestInterval["REFRESH"];
- }
- }
- // ---------------------------------- //
- // Update local user status
- if (Now > GlobalChat_NextRequestTime["SET_STATUS"]) {
- // Destroy ongoing request and start new
- if (GlobalChat_Requests["SET_STATUS"] != Null) {
- Http.Destroy(GlobalChat_Requests["SET_STATUS"]);
- GlobalChat_Requests["SET_STATUS"] = Null;
- }
- // Start new request
- if (GlobalChat_Requests["SET_STATUS"] == Null) {
- GlobalChat_Requests["SET_STATUS"] = Http.CreateGet(FormatURL(C_GlobalChatServerURL, [
- "act" => "SET_STATUS",
- "uid" => TL::ToText(Persistent_Evidence_GlobalChatUID),
- "login" => LocalUser.Login, "name" => LocalUser.Name,
- "presence" => TL::ToText(CurrentPluginPresenceId),
- "status" => CurrentPluginStatusText
- ]), False);
- GlobalChat_NextRequestTime["SET_STATUS"] = Now + C_GlobalChatRequestInterval["SET_STATUS"];
- }
- }
- // ---------------------------------- //
- // Start users list request
- if (Now > GlobalChat_NextRequestTime["GET_USER_LIST"]) {
- // Destroy ongoing request and start new
- if (GlobalChat_Requests["GET_USER_LIST"] != Null) {
- Http.Destroy(GlobalChat_Requests["GET_USER_LIST"]);
- GlobalChat_Requests["GET_USER_LIST"] = Null;
- }
- // Start new request
- if (GlobalChat_Requests["GET_USER_LIST"] == Null) {
- GlobalChat_Requests["GET_USER_LIST"] = Http.CreateGet(FormatURL(C_GlobalChatServerURL, ["act" => "GET_USER_LIST"]), False);
- GlobalChat_NextRequestTime["GET_USER_LIST"] = Now + C_GlobalChatRequestInterval["GET_USER_LIST"];
- }
- }
- // ---------------------------------- //
- // Update users list from request result
- if (GlobalChat_Requests["GET_USER_LIST"] != Null && GlobalChat_Requests["GET_USER_LIST"].IsCompleted) {
- // Get result and destroy request
- declare RequestResult = GlobalChat_Requests["GET_USER_LIST"].Result;
- Http.Destroy(GlobalChat_Requests["GET_USER_LIST"]);
- GlobalChat_Requests["GET_USER_LIST"] = Null;
- // Load users data
- if (RequestResult != "") {
- declare XMLDocument = Xml.Create(RequestResult);
- LoadUsersData(XMLDocument);
- Xml.Destroy(XMLDocument);
- }
- }
- // ---------------------------------- //
- // Start messages list request
- if (Now > GlobalChat_NextRequestTime["GET_MSG"]) {
- // Destroy ongoing request and start new
- if (GlobalChat_Requests["GET_MSG"] != Null) {
- Http.Destroy(GlobalChat_Requests["GET_MSG"]);
- GlobalChat_Requests["GET_MSG"] = Null;
- }
- // Start new request
- if (GlobalChat_Requests["GET_MSG"] == Null) {
- GlobalChat_Requests["GET_MSG"] = Http.CreateGet(FormatURL(C_GlobalChatServerURL, ["act" => "GET_MSG"]), False);
- GlobalChat_NextRequestTime["GET_MSG"] = Now + C_GlobalChatRequestInterval["GET_MSG"];
- }
- }
- // ---------------------------------- //
- // Update messages list from request result
- if (GlobalChat_Requests["GET_MSG"] != Null && GlobalChat_Requests["GET_MSG"].IsCompleted) {
- // Get result and destroy request
- declare RequestResult = GlobalChat_Requests["GET_MSG"].Result;
- Http.Destroy(GlobalChat_Requests["GET_MSG"]);
- GlobalChat_Requests["GET_MSG"] = Null;
- // Load messages data
- if (RequestResult != "") {
- declare XMLDocument = Xml.Create(RequestResult);
- LoadMessages(XMLDocument);
- Xml.Destroy(XMLDocument);
- }
- }
- }
- ***
- // ---------------------------------- //
- // Functions
- // ---------------------------------- //
- // ---------------------------------- //
- /** Get interface layer from attach Id
- *
- * @param _LayerId Text Id of the layer
- *
- * @return First layer with matching Id
- */
- CUILayer GetLayerFromId(Text _LayerId) {
- if (_LayerId == "") return Null;
- foreach (Layer in UILayers) if (Layer.AttachId == _LayerId) return Layer;
- return Null;
- }
- // ---------------------------------- //
- /** Send message to a player
- *
- * @param _ReceipentLogin Login of the player to send message to
- * @param _MessageType Type of the message
- * @param _MessageBody Message text contents
- */
- Void SendMessage(Text _ReceipentLogin, Text _MessageType, Text _MessageBody) {
- if (_MessageBody == "") return;
- declare LoginsToAvoid = ["", LocalUser.Login, "*group*", "*global*"];
- if (LoginsToAvoid.exists(_ReceipentLogin)) return;
- declare Receipent = BuddiesManager.GetBuddyFromLogin(_ReceipentLogin);
- if (Receipent == Null) return;
- BuddiesManager.SendMessage(Receipent, _MessageType, _MessageBody);
- }
- // ---------------------------------- //
- /** Get presence ID from presence enumerator
- *
- * @param _PresenceShow Buddy presence
- *
- * @return Presence ID
- */
- Integer GetPresenceId(CBuddy::EPresenceShow _PresenceShow) {
- switch (_PresenceShow) {
- case CBuddy::EPresenceShow::Available : return 1;
- case CBuddy::EPresenceShow::Away : return 2;
- case CBuddy::EPresenceShow::DoNotDisturb : return 3;
- case CBuddy::EPresenceShow::WantToChat : return 4;
- case CBuddy::EPresenceShow::ExtendedAway : return 5;
- }
- return 0;
- }
- // ---------------------------------- //
- /** Get presence enumerator from its Id
- *
- * @param _PresenceId Id of the presence to get
- *
- * @return Presence enumerator value
- */
- CBuddiesManager::EPresenceShow GetPresenceFromId(Integer _PresenceId) {
- switch (_PresenceId) {
- case 2 : return CBuddiesManager::EPresenceShow::Away;
- case 3 : return CBuddiesManager::EPresenceShow::DoNotDisturb;
- case 4 : return CBuddiesManager::EPresenceShow::WantToChat;
- case 5 : return CBuddiesManager::EPresenceShow::ExtendedAway;
- }
- return CBuddiesManager::EPresenceShow::Available;
- }
- // ---------------------------------- //
- /** Get permissions level required to perform specified command
- *
- * @param _Command Command to check permissions
- *
- * @return Required permissions level
- */
- Integer GetCommandPermissionsLevel(Text _Command) {
- if (C_GroupCommandPermissionsLevels.existskey(_Command))
- return C_GroupCommandPermissionsLevels[_Command];
- return 0;
- }
- // ---------------------------------- //
- /** Get permissions level of specific user
- *
- * @param _Command Command to check permissions
- *
- * @return Required permissions level
- */
- Integer GetUserPermissionsLevel(Text _UserLogin) {
- // User is host
- if (_UserLogin == LocalUser.Login) return 2;
- // User is operator
- declare persistent Text[] Persistent_Evidence_GroupOperators;
- if (Persistent_Evidence_GroupOperators.exists(_UserLogin)) return 1;
- // Standard user
- return 0;
- }
- // ---------------------------------- //
- /** Get name of the permissions level
- *
- * @param _PermissionsLevel Level to get name
- *
- * @return Name of the permissions level
- */
- Text GetPermissionsLevelName(Integer _PermissionsLevel) {
- switch (_PermissionsLevel) {
- case 2 : return "Host";
- case 1 : return "Operator";
- }
- return "User";
- }
- // ---------------------------------- //
- /** Get user name from login
- *
- * @param _UserLogin Find name of user with this login
- *
- * @return Name of the found player or initial login
- */
- Text GetNameFromLogin(Text _UserLogin) {
- if (_UserLogin == "") return "";
- if (_UserLogin == LocalUser.Login) return LocalUser.Name;
- // Find with matchfinding
- declare MatchingBuddiesName = Text[];
- if (TL::Find(_UserLogin, LocalUser.Login, False, False)) MatchingBuddiesName.add(LocalUser.Name);
- foreach (Buddy in BuddiesManager.Buddies) {
- if (Buddy.Login == _UserLogin) return Buddy.Name;
- if (TL::Find(_UserLogin, Buddy.Login, False, False)) MatchingBuddiesName.add(Buddy.Name);
- }
- foreach (Buddy in BuddiesManager.IncomingBuddyRequests) {
- if (Buddy.Login == _UserLogin) return Buddy.Name;
- if (TL::Find(_UserLogin, Buddy.Login, False, False)) MatchingBuddiesName.add(Buddy.Name);
- }
- foreach (Buddy in BuddiesManager.OutgoingBuddyRequests) {
- if (Buddy.Login == _UserLogin) return Buddy.Name;
- if (TL::Find(_UserLogin, Buddy.Login, False, False)) MatchingBuddiesName.add(Buddy.Name);
- }
- if (MatchingBuddiesName.count == 1) return MatchingBuddiesName[0];
- return _UserLogin;
- }
- // ---------------------------------- //
- /** Remove format from nicknames
- *
- * @param _Message Message to remove names format
- *
- * @return Message without format in nicknames
- */
- Text RemoveNamesFormat(Text _Message) {
- if (_Message == "") return "";
- declare OutputMessage = _Message;
- declare Text[] Nicknames;
- foreach (Buddy in BuddiesManager.Buddies) Nicknames.add(Buddy.Name);
- foreach (Buddy in BuddiesManager.IncomingBuddyRequests) Nicknames.add(Buddy.Name);
- foreach (Buddy in BuddiesManager.OutgoingBuddyRequests) Nicknames.add(Buddy.Name);
- foreach (Name in Nicknames)
- if (TL::Find(Name, OutputMessage, False, False))
- OutputMessage = TL::Replace(OutputMessage, Name, TL::StripFormatting(Name));
- return OutputMessage;
- }
- // ---------------------------------- //
- /** Send message to everyone in the group
- *
- * @param _SenderLogin Message sender login
- * @param _Message Message contents
- */
- Void SendMessageToGroup(Text _SenderLogin, Text _Message) {
- if (_Message == "") return;
- declare FormattedMessage = _Message;
- if (_SenderLogin != "") FormattedMessage = C_GroupFormatMessage^"[$<"^GetNameFromLogin(_SenderLogin)^"$>] "^_Message;
- // ---------------------------------- //
- // Persistent settings
- declare persistent Text[] Persistent_Evidence_BuddiesInGroup;
- declare persistent Text[] Persistent_Evidence_DisabledNoformat;
- // ---------------------------------- //
- // Send message to buddies
- foreach (Login in Persistent_Evidence_BuddiesInGroup) {
- if (Login == _SenderLogin) continue;
- // Remove nicknames format from message
- declare Text MessageForBuddy;
- if (!Persistent_Evidence_DisabledNoformat.exists(Login))
- MessageForBuddy = RemoveNamesFormat(FormattedMessage);
- else
- MessageForBuddy = FormattedMessage;
- SendMessage(Login, "", MessageForBuddy);
- }
- // ---------------------------------- //
- // Display message on host's screen
- declare WindowLayer = GetLayerFromId("WindowLayer");
- declare WindowPage <=> WindowLayer.LocalPage;
- declare Text[][] NewReceivedMessages for WindowPage;
- NewReceivedMessages.add(["*group*", _SenderLogin, _Message]);
- }
- // ---------------------------------- //
- /** Process command sent to the Group Chat server
- *
- * @param _CommandPerformer User that sent command
- * @param _MessageBody Message contents
- */
- Void PerformChatCommand(Text _CommandPerformer, Text _MessageBody) {
- if (_CommandPerformer == "" || _MessageBody == "") return;
- declare SplitCommand = TL::Split(" ", TL::SubString(_MessageBody, 1, TL::Length(_MessageBody) - 1));
- if (SplitCommand.count <= 0) return;
- declare CommandType = SplitCommand[0];
- declare Buddy = BuddiesManager.GetBuddyFromLogin(_CommandPerformer);
- declare UserLevelName = GetPermissionsLevelName(GetUserPermissionsLevel(_CommandPerformer));
- declare Text ExceptionMessage;
- // ---------------------------------- //
- // Get command sender name
- declare Text UserName;
- if (_CommandPerformer == LocalUser.Login) UserName = LocalUser.Name;
- else if (Buddy != Null) UserName = Buddy.Name;
- // ---------------------------------- //
- // Persistent settings
- declare persistent Text[] Persistent_Evidence_BuddiesInGroup;
- declare persistent Text[] Persistent_Evidence_GroupOperators;
- declare persistent Text[] Persistent_Evidence_GroupBannedUsers;
- declare persistent Text[] Persistent_Evidence_MutedGroupBuddies;
- declare persistent Text[] Persistent_Evidence_DisabledNoformat;
- declare persistent Text[Text] Persistent_Evidence_LastPMLogins;
- // ---------------------------------- //
- // Get manialink layer
- declare WindowLayer = GetLayerFromId("WindowLayer");
- declare WindowPage <=> WindowLayer.LocalPage;
- // ---------------------------------- //
- // Share variables with manialink
- declare Text[][] NewReceivedMessages for WindowPage;
- declare Text GroupChatPassword for WindowPage;
- // ---------------------------------- //
- // Overall: join command
- if (CommandType == "join") {
- declare Text RequestedPassword;
- foreach (I => Word in SplitCommand) if (I > 0) {
- if (I > 1) RequestedPassword ^= " ";
- RequestedPassword ^= Word;
- }
- // Host tries to connect to itself
- if (_CommandPerformer == LocalUser.Login)
- NewReceivedMessages.add(["*group*", "", C_GroupFormatError^"You're the host!"]);
- // User is already connected
- else if (Persistent_Evidence_BuddiesInGroup.exists(_CommandPerformer))
- BuddiesManager.SendMessage(Buddy, "", C_GroupFormatError^"You're already connected!");
- // User is banned
- else if (Persistent_Evidence_GroupBannedUsers.exists(_CommandPerformer))
- BuddiesManager.SendMessage(Buddy, "", C_GroupFormatError^"You're banned in this group!");
- // Add user to the group
- else if (GroupChatPassword == "" || RequestedPassword == GroupChatPassword) {
- Persistent_Evidence_BuddiesInGroup.add(_CommandPerformer);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> joined the group");
- PerformChatCommand(_CommandPerformer, "/list");
- }
- // User joins without password
- else if (RequestedPassword == "")
- BuddiesManager.SendMessage(Buddy, "", C_GroupFormatError^"You must enter a password to connect: /join <password>");
- // User sent wrong password
- else BuddiesManager.SendMessage(Buddy, "", C_GroupFormatError^"Incorrect password!");
- return;
- }
- // ---------------------------------- //
- // Ignore all commands if user is not in the group
- else if (_CommandPerformer != LocalUser.Login && !Persistent_Evidence_BuddiesInGroup.exists(_CommandPerformer)) return;
- // ---------------------------------- //
- // Check user permissions
- if (GetUserPermissionsLevel(_CommandPerformer) < GetCommandPermissionsLevel(CommandType))
- ExceptionMessage = "You don't have enough permissions!";
- // ---------------------------------- //
- // Perform apecific command
- switch (CommandType) {
- // ---------------------------------- //
- // Leave the group
- case "quit" : {
- if (_CommandPerformer != LocalUser.Login) {
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> has left the group");
- declare Removed = Persistent_Evidence_BuddiesInGroup.remove(_CommandPerformer);
- return;
- }
- // Host tries to leave
- else ExceptionMessage = "You're the host!";
- }
- // ---------------------------------- //
- // Commands help
- case "help" : {
- declare Text ComposedMessage;
- declare Text CommandToShowHelp;
- if (SplitCommand.existskey(1)) CommandToShowHelp = SplitCommand[1];
- // Show help for specified command
- if (C_GroupCommandsHelp.existskey(CommandToShowHelp))
- ComposedMessage = C_GroupCommandsHelp[CommandToShowHelp];
- // Show help for the formatted message command
- else if (C_ChatMessageCommands.existskey(CommandToShowHelp))
- ComposedMessage = "/"^CommandToShowHelp^" "^C_GroupCommandsHelp["/chatmsg"];
- // Show list of all available commands
- else {
- ComposedMessage = "Available commands: ";
- declare Text[] AllCommands;
- foreach (Command => Help in C_GroupCommandsHelp) if (Command != "/chatmsg") AllCommands.add(Command);
- foreach (Command => Message in C_ChatMessageCommands) AllCommands.add(Command);
- AllCommands = AllCommands.sort();
- foreach (I => Command in AllCommands) {
- if (I > 0) ComposedMessage ^= ", ";
- ComposedMessage ^= Command;
- }
- ComposedMessage ^= ".";
- }
- // Send message to buddy
- if (_CommandPerformer == LocalUser.Login) NewReceivedMessages.add(["*group*", "", C_GroupFormatInfo^ComposedMessage]);
- else BuddiesManager.SendMessage(Buddy, "", C_GroupFormatInfo^ComposedMessage);
- return;
- }
- // ---------------------------------- //
- // Me
- case "me" : {
- // User is muted
- if (Persistent_Evidence_MutedGroupBuddies.exists(_CommandPerformer))
- ExceptionMessage = "You're muted in this group!";
- // Send message
- else if (SplitCommand.existskey(1)) {
- declare Text CommandText;
- foreach (I => Word in SplitCommand) if (I > 0) CommandText ^= Word^" ";
- SendMessageToGroup("", C_GroupFormatInfo^"$<"^UserName^"$> $i"^CommandText);
- return;
- }
- // Missing parameters
- else ExceptionMessage = "Usage: /me [message]";
- }
- // ---------------------------------- //
- // Create list
- case "list" : {
- declare OutputMessage = C_GroupFormatInfo;
- declare Text ListType;
- if (SplitCommand.existskey(1)) ListType = SplitCommand[1];
- switch (ListType) {
- // ---------------------------------- //
- // Banned users list
- case "ban" : {
- OutputMessage ^= "Banned users ("^Persistent_Evidence_GroupBannedUsers.count^"): ";
- foreach (I => Login in Persistent_Evidence_GroupBannedUsers) {
- if (I > 0) OutputMessage ^= ", ";
- OutputMessage ^= Login;
- }
- }
- // ---------------------------------- //
- // Muted users list
- case "muted" : {
- OutputMessage ^= "Muted users ("^Persistent_Evidence_MutedGroupBuddies.count^"): ";
- foreach (I => Login in Persistent_Evidence_MutedGroupBuddies) {
- if (I > 0) OutputMessage ^= ", ";
- OutputMessage ^= Login;
- }
- }
- // ---------------------------------- //
- // Operators list
- case "op" : {
- OutputMessage ^= "Group operators ("^1 + Persistent_Evidence_GroupOperators.count^"): "^LocalUser.Login;
- foreach (I => Login in Persistent_Evidence_GroupOperators) OutputMessage ^= ", "^Login;
- }
- // ---------------------------------- //
- // Operators list
- case "nf" : {
- OutputMessage ^= "Users that disabled \"noformat\" option ("^Persistent_Evidence_DisabledNoformat.count^"): ";
- foreach (I => Login in Persistent_Evidence_DisabledNoformat) {
- if (I > 0) OutputMessage ^= ", ";
- OutputMessage ^= Login;
- }
- }
- // ---------------------------------- //
- // List of all available logins to format name
- case "logins" : {
- declare Text[] AvailableLogins;
- foreach (Buddy in BuddiesManager.Buddies) AvailableLogins.add(Buddy.Login);
- foreach (Buddy in BuddiesManager.IncomingBuddyRequests) AvailableLogins.add(Buddy.Login);
- foreach (Buddy in BuddiesManager.OutgoingBuddyRequests) AvailableLogins.add(Buddy.Login);
- AvailableLogins = AvailableLogins.sort();
- OutputMessage ^= "Available logins ("^1 + AvailableLogins.count^"): "^LocalUser.Login;
- foreach (I => Login in AvailableLogins) OutputMessage ^= ", "^Login;
- }
- // ---------------------------------- //
- // Connected users list
- default : {
- OutputMessage ^= "Users online ("^1 + Persistent_Evidence_BuddiesInGroup.count^"): "^LocalUser.Login;
- foreach (Login in Persistent_Evidence_BuddiesInGroup) OutputMessage ^= ", "^Login;
- }
- }
- // Display list on user screen
- if (_CommandPerformer == LocalUser.Login) NewReceivedMessages.add(["*group*", "", OutputMessage]);
- else BuddiesManager.SendMessage(Buddy, "", OutputMessage);
- return;
- }
- // ---------------------------------- //
- // Kick user
- case "kick" : {
- declare Text ExceptionMessage;
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToMute = SplitCommand[1];
- // User tried to kick host
- if (LoginToMute == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not connected
- else if (!Persistent_Evidence_BuddiesInGroup.exists(LoginToMute))
- ExceptionMessage = "User not found!";
- // Operator tries to kick another operator
- else if (GetUserPermissionsLevel(_CommandPerformer) <= 1 && GetUserPermissionsLevel(LoginToMute) >= 1)
- ExceptionMessage = "You can't kick other operators!";
- // Kick specified user
- else {
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> kicked $<"^GetNameFromLogin(LoginToMute)^"$>!");
- PerformChatCommand(LoginToMute, "/quit");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /kick [login]";
- }
- // ---------------------------------- //
- // Ban user
- case "ban" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToBan = SplitCommand[1];
- // User tried to ban host
- if (LoginToBan == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not connected
- else if (!Persistent_Evidence_BuddiesInGroup.exists(LoginToBan))
- ExceptionMessage = "User not found!";
- // User is already banned
- else if (Persistent_Evidence_GroupBannedUsers.exists(LoginToBan))
- ExceptionMessage = "Requested user is already banned!";
- // Operator tries to ban another operator
- else if (GetUserPermissionsLevel(_CommandPerformer) <= 1 && GetUserPermissionsLevel(LoginToBan) >= 1)
- ExceptionMessage = "You can't ban other operators!";
- // Ban specified user
- else {
- Persistent_Evidence_GroupBannedUsers.add(LoginToBan);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> banned $<"^GetNameFromLogin(LoginToBan)^"$>!");
- PerformChatCommand(LoginToBan, "/quit");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /ban [login]";
- }
- // ---------------------------------- //
- // Unban user
- case "unban" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToUnban = SplitCommand[1];
- // User tried to ban host
- if (LoginToUnban == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not banned
- else if (!Persistent_Evidence_GroupBannedUsers.exists(LoginToUnban))
- ExceptionMessage = "Requested user is not banned!";
- // Operator tries to unban another operator
- else if (GetUserPermissionsLevel(_CommandPerformer) <= 1 && GetUserPermissionsLevel(LoginToUnban) >= 1)
- ExceptionMessage = "You can't unban other operators!";
- // Unban specified user
- else {
- declare Removed = Persistent_Evidence_GroupBannedUsers.remove(LoginToUnban);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> unbanned $<"^GetNameFromLogin(LoginToUnban)^"$>!");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /unban [login]";
- }
- // ---------------------------------- //
- // Mute user
- case "mute" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToMute = SplitCommand[1];
- // User tried to mute host
- if (LoginToMute == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not connected
- else if (!Persistent_Evidence_BuddiesInGroup.exists(LoginToMute))
- ExceptionMessage = "User not found!";
- // User is already muted
- else if (Persistent_Evidence_MutedGroupBuddies.exists(LoginToMute))
- ExceptionMessage = "Requested user is already muted!";
- // Operator tries to mute another operator
- else if (GetUserPermissionsLevel(_CommandPerformer) <= 1 && GetUserPermissionsLevel(LoginToMute) >= 1)
- ExceptionMessage = "You can't mute other operators!";
- // Mute specified user
- else {
- Persistent_Evidence_MutedGroupBuddies.add(LoginToMute);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> muted $<"^GetNameFromLogin(LoginToMute)^"$>!");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /mute [login]";
- }
- // ---------------------------------- //
- // Unmute user
- case "unmute" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToUnmute = SplitCommand[1];
- // User tried to mute host
- if (LoginToUnmute == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not muted
- else if (!Persistent_Evidence_MutedGroupBuddies.exists(LoginToUnmute))
- ExceptionMessage = "Requested user is not muted!";
- // Operator tries to unmute another operator
- else if (GetUserPermissionsLevel(_CommandPerformer) <= 1 && GetUserPermissionsLevel(LoginToUnmute) >= 1)
- ExceptionMessage = "You can't unmute other operators!";
- // Unmute specified user
- else {
- declare Removed = Persistent_Evidence_MutedGroupBuddies.remove(LoginToUnmute);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> unmuted $<"^GetNameFromLogin(LoginToUnmute)^"$>!");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /unmute [login]";
- }
- // ---------------------------------- //
- // Give operator rights
- case "addop" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToSetOp = SplitCommand[1];
- // User tried to give host operator rights
- if (LoginToSetOp == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not connected
- else if (!Persistent_Evidence_BuddiesInGroup.exists(LoginToSetOp))
- ExceptionMessage = "User not found!";
- // User already is operator
- else if (GetUserPermissionsLevel(LoginToSetOp) >= 1)
- ExceptionMessage = "Requested user already has operator rights!";
- // Give operator rights
- else {
- Persistent_Evidence_GroupOperators.add(LoginToSetOp);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> gave $<"^GetNameFromLogin(LoginToSetOp)^"$> operator rights!");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /addop [login]";
- }
- // ---------------------------------- //
- // Unmute
- case "removeop" : {
- if (SplitCommand.existskey(1) && SplitCommand[1] != "") {
- declare LoginToRemoveOp = SplitCommand[1];
- // User tried to remove operator rights from host
- if (LoginToRemoveOp == LocalUser.Login) ExceptionMessage = "Requested user is the host!";
- // User is not operator
- else if (GetUserPermissionsLevel(LoginToRemoveOp) < 1)
- ExceptionMessage = "Requested user is not operator!";
- // Remove operator rights
- else {
- declare Removed = Persistent_Evidence_GroupOperators.remove(LoginToRemoveOp);
- SendMessageToGroup("", C_GroupFormatSuccess^UserLevelName^" $<"^UserName^"$> took operator rights from $<"^GetNameFromLogin(LoginToRemoveOp)^"$>!");
- return;
- }
- }
- // Login not specified
- else ExceptionMessage = "Usage: /removeop [login]";
- }
- // ---------------------------------- //
- // Send private message
- case "pm" : {
- if (SplitCommand.existskey(2)) {
- declare MessageRecipient = SplitCommand[1];
- // Sender is muted
- if (Persistent_Evidence_MutedGroupBuddies.exists(_CommandPerformer))
- ExceptionMessage = "You're muted in this group!";
- // User is sending message to himself
- else if (MessageRecipient == _CommandPerformer)
- ExceptionMessage = "You can't send private messages to yourself!";
- // User not found
- else if (!Persistent_Evidence_BuddiesInGroup.exists(MessageRecipient) && MessageRecipient != LocalUser.Login)
- ExceptionMessage = "User not found!";
- // Send message
- else {
- declare Text ComposedMessage;
- foreach (I => Word in SplitCommand) if (I >= 2) ComposedMessage ^= " "^Word;
- // Sender message
- declare SenderMessageText = C_GroupFormatPrivate^"[To $<"^GetNameFromLogin(MessageRecipient)^"$>]"^ComposedMessage;
- if (_CommandPerformer != LocalUser.Login) BuddiesManager.SendMessage(Buddy, "", SenderMessageText);
- else NewReceivedMessages.add(["*group*", LocalUser.Login, SenderMessageText]);
- // Receipent message
- declare RecipientMessageText = C_GroupFormatPrivate^"[From $<"^UserName^"$>]"^ComposedMessage;
- if (MessageRecipient == LocalUser.Login) NewReceivedMessages.add(["*group*", _CommandPerformer, RecipientMessageText]);
- else BuddiesManager.SendMessage(BuddiesManager.GetBuddyFromLogin(MessageRecipient), "", RecipientMessageText);
- // Save latest message sender
- Persistent_Evidence_LastPMLogins[_CommandPerformer] = MessageRecipient;
- Persistent_Evidence_LastPMLogins[MessageRecipient] = _CommandPerformer;
- return;
- }
- }
- // Message not specified
- else if (SplitCommand.existskey(1))
- ExceptionMessage = "Usage: /pm "^SplitCommand[1]^" [message]";
- // Login not specified
- else ExceptionMessage = "Usage: /pm [login] [message]";
- }
- // ---------------------------------- //
- // Reply to latest private message
- case "pmr" : {
- if (SplitCommand.existskey(1)) {
- // Sender is muted
- if (Persistent_Evidence_MutedGroupBuddies.exists(_CommandPerformer))
- ExceptionMessage = "You're muted in this group!";
- // User hasn't contacted anyone yet
- if (!Persistent_Evidence_LastPMLogins.existskey(_CommandPerformer))
- ExceptionMessage = "You haven't started any private conversation yet!";
- // Send message
- else {
- declare Text ComposedMessage;
- foreach (I => Word in SplitCommand) if (I >= 1) ComposedMessage ^= " "^Word;
- declare Recipient = Persistent_Evidence_LastPMLogins[_CommandPerformer];
- PerformChatCommand(_CommandPerformer, "/pm "^Recipient^ComposedMessage);
- return;
- }
- }
- // Message not specified
- else ExceptionMessage = "Usage: /pmr [message]";
- }
- // ---------------------------------- //
- // Set noformat option
- case "noformat" : {
- declare PrevNoformatSetting = !Persistent_Evidence_DisabledNoformat.exists(_CommandPerformer);
- declare Text InformationMessage;
- if (SplitCommand.existskey(1)) {
- declare NewSettingValue = SplitCommand[1] == "1";
- // Invalid value
- if (SplitCommand[1] != "0" && SplitCommand[1] != "1")
- ExceptionMessage = "Only accepted boolean values are \"0\" and \"1\"!";
- // New setting is the same
- else if (NewSettingValue == PrevNoformatSetting)
- ExceptionMessage = "Option \"noformat\" is already set to \""^NewSettingValue^"\"!";
- // Change setting
- else {
- InformationMessage = C_GroupFormatInfo^"Option \"noformat\" has been set to \""^NewSettingValue^"\"!";
- if (!PrevNoformatSetting) {
- declare Removed = Persistent_Evidence_DisabledNoformat.remove(_CommandPerformer);
- } else
- Persistent_Evidence_DisabledNoformat.add(_CommandPerformer);
- }
- }
- // Setting not specified
- else InformationMessage = C_GroupFormatInfo^"Option \"noformat\" is set to \""^PrevNoformatSetting^"\".";
- if (InformationMessage != "") {
- if (_CommandPerformer != LocalUser.Login) BuddiesManager.SendMessage(Buddy, "", InformationMessage);
- else NewReceivedMessages.add(["*group*", "", InformationMessage]);
- return;
- }
- }
- // ---------------------------------- //
- // Show script information
- case "core" : {
- declare ComposedMessage = ScriptName^" v"^ScriptVersionNb^" @"^ScriptVersion;
- if (_CommandPerformer != LocalUser.Login) BuddiesManager.SendMessage(Buddy, "", C_GroupFormatInfo^ComposedMessage);
- else NewReceivedMessages.add(["*group*", "", C_GroupFormatInfo^ComposedMessage]);
- return;
- }
- // ---------------------------------- //
- // Ragequit
- case "rq" : {
- if (_CommandPerformer != LocalUser.Login) {
- SendMessageToGroup("", "$F00$<"^UserName^"$> $isaid !@#$$% and ragequit.");
- PerformChatCommand(_CommandPerformer, "/quit");
- return;
- }
- // Host tries to leave
- else ExceptionMessage = "You're the host!";
- }
- // ---------------------------------- //
- // Bootme
- case "bm" : {
- if (_CommandPerformer != LocalUser.Login) {
- SendMessageToGroup("", C_GroupFormatInfo^"$<"^UserName^"$> $ichooses to boot back to the real world!");
- PerformChatCommand(_CommandPerformer, "/quit");
- return;
- }
- // Host tries to leave
- else ExceptionMessage = "You're the host!";
- }
- }
- // ---------------------------------- //
- // Formatted chat messages
- if (C_ChatMessageCommands.existskey(CommandType)) {
- if (!Persistent_Evidence_MutedGroupBuddies.exists(_CommandPerformer)) {
- declare ComposedMessage = "$i"^C_ChatMessageCommands[CommandType];
- // Attach additional username
- if (SplitCommand.existskey(1) && SplitCommand[1] != "" && C_ChatMessageWithLogin.exists(CommandType))
- ComposedMessage ^= " $i$<"^GetNameFromLogin(SplitCommand[1])^"$>$i";
- ComposedMessage ^= "!";
- SendMessageToGroup(_CommandPerformer, ComposedMessage);
- return;
- }
- // User is muted
- else ExceptionMessage = "You're muted in this group!";
- }
- // ---------------------------------- //
- // Command unknown
- if (ExceptionMessage == "") ExceptionMessage = "Command unknown";
- // ---------------------------------- //
- // Show exception message
- if (_CommandPerformer != LocalUser.Login) BuddiesManager.SendMessage(Buddy, "", C_GroupFormatError^ExceptionMessage);
- else NewReceivedMessages.add(["*group*", "", C_GroupFormatError^ExceptionMessage]);
- }
- // ---------------------------------- //
- /** Format URL from given base and query
- *
- * @param _URL Base of the URL
- * @param _Query Elements of the query
- *
- * @return Complete URL
- */
- Text FormatURL(Text _URL, Text[Text] _Query) {
- if (_URL == "" || !Http.IsValidUrl(_URL)) return "";
- declare Text QueryText;
- declare I = 0;
- foreach (Name => Value in _Query) {
- if (I == 0) QueryText ^= "?";
- else QueryText ^= "&";
- QueryText ^= TL::URLEncode(Name)^"="^TL::URLEncode(Value);
- I += 1;
- }
- return _URL^QueryText;
- }
- // ---------------------------------- //
- /** Load users list and data from request XML result
- *
- * @param _Document XML document with users data
- */
- Void LoadUsersData(CXmlDocument _Document) {
- if (_Document == Null || _Document.Root == Null || _Document.Root.Name != "users") return;
- // ---------------------------------- //
- // Get manialink layer
- declare WindowLayer = GetLayerFromId("WindowLayer");
- if (WindowLayer == Null) return;
- declare WindowPage <=> WindowLayer.LocalPage;
- if (WindowPage == Null) return;
- // ---------------------------------- //
- // Share variables with manialink
- declare Text[] BuddiesList_GlobalList for WindowPage;
- declare Text[Text] GlobalChat_BuddiesName for WindowPage;
- declare Integer[Text] GlobalChat_BuddiesPresenceId for WindowPage;
- declare Text[Text] GlobalChat_BuddiesStatus for WindowPage;
- // Clear previous data
- BuddiesList_GlobalList.clear();
- declare LocalUserExists = False;
- // ---------------------------------- //
- // Read nodes data
- foreach (Node in _Document.Root.Children) {
- if (Node.Name == "user") {
- // Get user Login
- declare UserLogin = Node.GetAttributeText("login", "");
- if (UserLogin != "" && UserLogin != LocalUser.Login) {
- BuddiesList_GlobalList.add(UserLogin);
- // Get user name
- declare UserName = Node.GetAttributeText("name", "");
- if (UserName != "") GlobalChat_BuddiesName[UserLogin] = UserName;
- // Get user presence id
- declare UserPresenceId = Node.GetAttributeInteger("presenceid", 0);
- if (UserPresenceId < 1 || UserPresenceId > 5) UserPresenceId = 1;
- GlobalChat_BuddiesPresenceId[UserLogin] = UserPresenceId;
- // Get user status
- declare UserStatus = Node.GetAttributeText("status", "");
- if (UserStatus == "") UserStatus = C_UserPresenceStatus[UserPresenceId];
- GlobalChat_BuddiesStatus[UserLogin] = UserStatus;
- }
- if (UserLogin == LocalUser.Login) LocalUserExists = True;
- }
- }
- // Trigegr connection error
- if (!LocalUserExists) G_GlobalChat_ConnectionError = True;
- }
- // ---------------------------------- //
- /** Load messages data from request XML result
- *
- * @param _Document XML document with messages data
- */
- Void LoadMessages(CXmlDocument _Document) {
- if (_Document == Null || _Document.Root == Null || _Document.Root.Name != "messages") return;
- // ---------------------------------- //
- // Get manialink layer
- declare WindowLayer = GetLayerFromId("WindowLayer");
- if (WindowLayer == Null) return;
- declare WindowPage <=> WindowLayer.LocalPage;
- if (WindowPage == Null) return;
- // ---------------------------------- //
- // Share variables with manialink
- declare Text[][] NewReceivedMessages for WindowPage;
- // ---------------------------------- //
- // Read nodes data
- foreach (Node in _Document.Root.Children) {
- if (Node.Name == "msg") {
- // Get user Login
- declare UserLogin = Node.GetAttributeText("author", "");
- // Get message timestamp
- declare Timestamp = Node.GetAttributeInteger("timestamp", 0);
- // Get umessage body
- declare MessageBody = Node.GetAttributeText("body", "");
- if (UserLogin != "" && Timestamp > 0 && MessageBody != "") {
- if (!G_GlobalChat_ReceivedMessages.exists(Timestamp)) {
- G_GlobalChat_ReceivedMessages.add(Timestamp);
- NewReceivedMessages.add(["*global*", UserLogin, MessageBody]);
- }
- }
- }
- }
- }
- // ---------------------------------- //
- /** Create widget manialink
- *
- * @return The manialink
- */
- Text CreateManialinkPluginIcon() {
- return """
- <manialink version="2" name="Evidence:PluginIcon">
- <!-- Plugin icon frame -->
- <frame id="Frame_EvidencPluginIcon" posn="-8 90 1">
- <quad sizen="9.5 6" halign="right" bgcolor="0AF" opacity="0" id="Quad_PluginIconBgCard" ScriptEvents="1"/>
- <quad posn="-7 .25 1" sizen="6 6" colorize="FFF" image="http://i.imgur.com/zWESBiR.png"/>
- <label posn="-7.5 -3 1" halign="right" valign="center2" textsize="2" textemboss="1" textcolor="FFF" id="Label_PluginIconUsers"/>
- <!-- Plugin icon notifications amount -->
- <frame id="Frame_PluginIconNotice" posn="-2 -1.5 2" hidden="1">
- <quad sizen="2.5 2.5" halign="center" valign="center" image="file://Media/Manialinks/Common/disc.dds" colorize="B00"/>
- <label posn="0 0 1" halign="center" valign="center2" style="TextValueSmallSm" scale=".45" textcolor="FFF" id="Label_PluginIconNotice"/>
- </frame>
- </frame>
- <script><!--
- /**
- * EVIDENCE by domino54
- * Plugin icon manialink
- */
- #Include "TextLib" as TL
- // ---------------------------------- //
- // Start manialink
- // ---------------------------------- //
- ***StartManialink***
- ***
- // ---------------------------------- //
- // Load interface elements
- declare Quad_PluginIconBgCard <=> (Page.GetFirstChild("Quad_PluginIconBgCard") as CMlQuad);
- declare Label_PluginIconUsers <=> (Page.GetFirstChild("Label_PluginIconUsers") as CMlLabel);
- declare Frame_PluginIconNotice <=> (Page.GetFirstChild("Frame_PluginIconNotice") as CMlFrame);
- declare Label_PluginIconNotice <=> (Page.GetFirstChild("Label_PluginIconNotice") as CMlLabel);
- // ---------------------------------- //
- // Plugin script communication
- declare PluginNbUsersOnline for Page = 0; ///< Amount of buddies online
- declare PluginNbUnreadMessages for Page = 0; ///< Amount of unread messages from buddies and group
- declare PluginIsChatWindowOpen for Page = False; ///< Current chat visibility status
- declare PluginTriggerOpenChat for Page = False; ///< Trigger chat visibility
- /// Update variables
- declare PrevNbBuddiesOnline = -1;
- ***
- // ---------------------------------- //
- // Yield
- // ---------------------------------- //
- ***Yield***
- ***
- // ---------------------------------- //
- // Events management
- foreach (Event in PendingEvents) {
- // ---------------------------------- //
- // Mouse click
- if (Event.Type == CMlEvent::Type::MouseClick) {
- if (Event.ControlId == "Quad_PluginIconBgCard") {
- PluginTriggerOpenChat = True;
- Audio.PlaySoundEvent(CAudioManager::ELibSound::Valid, 1, 0.);
- }
- }
- // ---------------------------------- //
- // Mouse over
- if (Event.Type == CMlEvent::Type::MouseOver) {
- if (Event.ControlId == "Quad_PluginIconBgCard") Quad_PluginIconBgCard.Opacity = .5;
- }
- // ---------------------------------- //
- // Mouse out
- if (Event.Type == CMlEvent::Type::MouseOut) {
- if (Event.ControlId == "Quad_PluginIconBgCard") Quad_PluginIconBgCard.Opacity = 0.;
- }
- }
- // ---------------------------------- //
- // Show amount of connected buddies
- if (PrevNbBuddiesOnline != PluginNbUsersOnline) {
- PrevNbBuddiesOnline = PluginNbUsersOnline;
- Label_PluginIconUsers.SetText(TL::ToText(PluginNbUsersOnline));
- Quad_PluginIconBgCard.Size.X = 9.5 + Label_PluginIconUsers.ComputeWidth(Label_PluginIconUsers.Value);
- }
- // ---------------------------------- //
- // Show amount of unread messages
- Frame_PluginIconNotice.Visible = (!PluginIsChatWindowOpen && PluginNbUnreadMessages > 0);
- if (Frame_PluginIconNotice.Visible) {
- Label_PluginIconNotice.Value = TL::ToText(PluginNbUnreadMessages);
- }
- ***
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- main() {
- +++StartManialink+++
- while (True) {
- +++Yield+++
- yield;
- }
- }
- --></script>
- </manialink>""";
- }
- // ---------------------------------- //
- /** Create dialog box manialink
- *
- * @return The manialink
- */
- Text CreateManialinkDialogBox() {
- return """
- <manialink version="2" name="Evidence:DialogBox" background="0">
- <frame id="Frame_DialogBox" posn="0 0 70" hidden="1">
- <quad posn="0 0 -1" sizen="320 180" halign="center" valign="center" style="Bgs1" substyle="BgDialogBlur" ScriptEvents="1"/>
- <quad posn="0 17 1" sizen="126.5 8" halign="center" style="Bgs1InRace" substyle="BgGlow2"/>
- <quad sizen="120 25" halign="center" valign="center" style="Bgs1InRace" substyle="BgWindow2"/>
- <quad posn="0 -12 1" sizen="120 2" halign="center" style="Bgs1InRace" substyle="BgMetalBar"/>
- <label posn="0 6.25" sizen="100 4" halign="center" valign="center2" textsize="2" textcolor="FFF" autonewline="1" id="Label_DialogMessage"/>
- <label posn="-32 -4 1" style="CardButtonMedium" valign="center" halign="center" text="Remove" translate="1" id="Label_ButtonRemove" ScriptEvents="1"/>
- <label posn="32 -4 1" style="CardButtonMedium" valign="center" halign="center" text="Cancel" translate="1" id="Label_ButtonCancel" ScriptEvents="1"/>
- </frame>
- <script><!--
- /**
- * EVIDENCE by domino54
- * Buddy removal dialog box
- */
- #Include "TextLib" as TL
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- ***Main***
- ***
- // ---------------------------------- //
- // Load interface elements
- declare Frame_DialogBox <=> (Page.GetFirstChild("Frame_DialogBox") as CMlFrame);
- declare Label_DialogMessage <=> (Page.GetFirstChild("Label_DialogMessage") as CMlLabel);
- // ---------------------------------- //
- // Script communication
- declare DialogVisible for Page = False; ///< Visibility of the dialog box
- declare DialogBuddyLogin for Page = ""; ///< Login of the buddy to remove
- declare DialogBuddyName for Page = ""; ///< Name of the buddy to remove
- /// Update variables
- declare PrevDialogVisible = False;
- ***
- // ---------------------------------- //
- // Yield
- // ---------------------------------- //
- ***Yield***
- ***
- // ---------------------------------- //
- // Events management
- foreach (Event in PendingEvents) {
- // ---------------------------------- //
- // Click on the interface element
- if (Event.Type == CMlEvent::Type::MouseClick) {
- // ---------------------------------- //
- // Button remove
- if (Event.ControlId == "Label_ButtonRemove") {
- SendCustomEvent("BuddyRemoved", [DialogBuddyLogin]);
- DialogVisible = False;
- }
- // ---------------------------------- //
- // Button cancel
- if (Event.ControlId == "Label_ButtonCancel") DialogVisible = False;
- }
- // ---------------------------------- //
- // Menu navigation
- if (Event.Type == CMlEvent::Type::MenuNavigation) {
- // ---------------------------------- //
- // Escape key
- if (Event.MenuNavAction == CMlEvent::EMenuNavAction::Cancel) DialogVisible = False;
- }
- }
- // ---------------------------------- //
- // Update visibility
- if (PrevDialogVisible != DialogVisible) {
- PrevDialogVisible = DialogVisible;
- EnableMenuNavigation(DialogVisible, True, Null, 10);
- // ---------------------------------- //
- // Set visibility
- Frame_DialogBox.Visible = DialogVisible;
- // ---------------------------------- //
- // Play sound
- declare TargetSound = CAudioManager::ELibSound::HideDialog;
- if (DialogVisible) TargetSound = CAudioManager::ELibSound::ShowDialog;
- Audio.PlaySoundEvent(TargetSound, 0, 0.);
- // ---------------------------------- //
- // Set buddy name
- if (DialogVisible) Label_DialogMessage.SetText(TL::Compose(_("Are you sure you want to remove $<%1$> from your buddy list?"), DialogBuddyName));
- }
- ***
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- main() {
- +++Main+++
- while (True) {
- yield;
- +++Yield+++
- }
- }
- --></script>
- </manialink>""";
- }
- // ---------------------------------- //
- /** Create window manialink
- *
- * @return The manialink
- */
- Text CreateManialinkWindow() {
- return """
- <?xml version="1.0" encoding="utf-8" standalone="yes"?>
- <manialink version="2" name="Evidence:ChatWindow" background="0">
- <stylesheet>
- <style id="Quad_BuddySlotBtnJoin" image="{{{C_ImgBase}}}buddy-join.dds" imagefocus="{{{C_ImgBase}}}buddy-join-on.dds"/>
- <style id="Quad_BuddySlotBtnAdd" image="{{{C_ImgBase}}}buddy-buddy-accept.dds" imagefocus="{{{C_ImgBase}}}buddy-buddy-accept-focus.dds"/>
- <style id="Quad_BuddySlotBtnDeny" image="{{{C_ImgBase}}}buddy-buddy-deny.dds" imagefocus="{{{C_ImgBase}}}buddy-buddy-deny-focus.dds"/>
- <style id="Quad_BuddySlotBtnPlus" image="{{{C_ImgBase}}}buddy-buddy-add.dds" imagefocus="{{{C_ImgBase}}}buddy-buddy-add-focus.dds"/>
- <style id="Quad_BuddySlotBtnKick" image="{{{C_ImgBase}}}buddy-delete-off.dds" imagefocus="{{{C_ImgBase}}}buddy-delete-focus.dds"/>
- <style id="Quad_BuddySlotBtnSearch" image="{{{C_ImgBase}}}buddy-search-go-off.dds" imagefocus="{{{C_ImgBase}}}buddy-search-go-focus.dds"/>
- <style id="Quad_MessageSlotBtnCopy" image="{{{C_ImgBase}}}buddy-copy-serverlink.dds" imagefocus="{{{C_ImgBase}}}buddy-copy-serverlink-on.dds"/>
- <style id="Quad_InvitePlayerButton" image="{{{C_ImgBase}}}buddy-buddy-add.dds" imagefocus="{{{C_ImgBase}}}buddy-buddy-add-focus.dds"/>
- <style id="Quad_SearchModeClose" image="{{{C_ImgBase}}}buddy-search-clear-off.dds" imagefocus="{{{C_ImgBase}}}buddy-search-clear-focus.dds"/>
- <style id="Label_MessengerBuddyName" style="TextValueSmallSm" textsize="2" textemboss="1" textcolor="FFF"/>
- <style id="Quad_MessengerBuddyRemove" image="{{{C_ImgBase}}}buddy-delete-off.dds" imagefocus="{{{C_ImgBase}}}buddy-delete-focus.dds"/>
- <style id="Quad_MessengerBuddyJoin" image="{{{C_ImgBase}}}buddy-join.dds" imagefocus="{{{C_ImgBase}}}buddy-join-on.dds"/>
- <style class="Check" sizen="4 4" valign="center" style="Icons64x64_1" substyle="Check"/>
- </stylesheet>
- <!-- Model of the mode change buttons -->
- <framemodel id="FrameModel_ModeButton">
- <quad sizen="6 6" halign="center" valign="center" colorize="FFF" class="ModeButton focus-2 valid-0" id="Quad_ModeButtonIcon" ScriptEvents="1"/>
- <frame id="Frame_ModeButtonNotice" posn="1.5 1.5 1" hidden="1">
- <quad sizen="2.5 2.5" halign="center" valign="center" image="file://Media/Manialinks/Common/disc.dds" colorize="B00"/>
- <label posn="0 0 1" halign="center" valign="center2" style="TextValueSmallSm" scale=".45" textcolor="FFF" id="Label_ModeButtonNotice"/>
- </frame>
- </framemodel>
- <!-- Model of the buddies list slots -->
- <framemodel id="FrameModel_BuddySlot">
- <quad posn="0 -.25" sizen="44 7.5" bgcolor="000" opacity=".125" class="valid-1" id="Quad_BuddySlotBgCard" ScriptEvents="1"/>
- <quad posn="0 -.25 .1" sizen="44 7.5" bgcolor="0AF" opacity="0" id="Quad_BuddySlotBlink"/>
- <label posn="43.5 -7.5 .2" halign="right" valign="bottom" scale=".5" textemboss="0" textcolor="0AF" id="Label_BuddySlotNbNotice"/>
- <!-- Presence lights -->
- <quad posn="0 -.25 1" sizen="1 7.5" opacity=".6" id="Quad_BuddySlotPresence"/>
- <quad posn="-2.3 2 .9" sizen="5.5 12" style="Bgs1InRace" substyle="BgButtonGlow" id="Quad_BuddySlotGlow" hidden="1"/>
- <!-- Name and status -->
- <label posn="2 -2.5 1" sizen="33.5 3" valign="center2" textsize="1" textcolor="FFF" id="Label_BuddySlotName"/>
- <label posn="2 -5.75 1" sizen="48.5 3" scale=".75" valign="center2" textsize="1" textcolor="FFF" maxline="1" id="Label_BuddySlotStatus"/>
- <label posn="43.5 -.5 1" halign="right" scale=".5" textcolor="0AF" text="E" id="Label_EvidenceUser" hidden="1"/>
- <!-- Control buttons -->
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnJoin" ScriptEvents="1" hidden="1"/>
- <quad posn="38.0 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnAdd" ScriptEvents="1" hidden="1"/>
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnDeny" ScriptEvents="1" hidden="1"/>
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnPlus" ScriptEvents="1" hidden="1"/>
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnKick" ScriptEvents="1" hidden="1"/>
- <quad posn="38.0 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnMute" ScriptEvents="1" hidden="1"/>
- <!-- Search mode buttons -->
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_BuddySlotBtnSearch" ScriptEvents="1" hidden="1"/>
- </framemodel>
- <!-- Model of the the messages items -->
- <framemodel id="FrameModel_MessageSlot">
- <quad posn="0 -.25" sizen="124 7.5" bgcolor="000" opacity=".25" id="Quad_MessageSlotBgCard"/>
- <quad posn="1 -2.5 1" sizen="2.25 2.25" valign="center" class="focus1 valid1" id="Quad_MessageSlotBtnCopy" ScriptEvents="1"/>
- <label posn="4 -2.5 1" sizen="80 4" valign="center2" scale=".9" textsize="1" textcolor="FFF" text="Buddy name" id="Label_MessageSlotName"/>
- <label posn="123 -2.5 1" halign="right" valign="center2" scale=".9" textsize="1" textcolor="FFF" opacity=".375" id="Label_MessageSlotTime"/>
- <label posn="1 -4.25 1" sizen="122" textsize="1" textemboss="1" textcolor="FFF" autonewline="1" text="Message body" id="Label_MessageSlotBody"/>
- <quad posn="1 -4.5 1" sizen="40 40" id="Quad_MessageSlotImage" keepratio="fit" hidden="1"/>
- </framemodel>
- <!-- Frame preventing going off screen while using VR devices -->
- <frame clip="1" clipsizen="320 180">
- <!-- Plugin window itself -->
- <frame id="Frame_EvidencePlugin" posn="0 204">
- <!-- Buddies list window -->
- <frame id="Frame_BuddiesList" posn="-24">
- <!-- Background images -->
- <quad sizen="48.5 106" image="file://Media/Manialinks/Common/background2.png" ScriptEvents="1"/>
- <quad posn="0 0 -1" sizen="48 104" style="Bgs1" substyle="BgDialogBlur" opacity="0"/>
- <quad posn="-3 3 1" sizen="54 7.5" style="Bgs1InRace" substyle="BgGlow2"/>
- <quad posn="0 -104.5 1" sizen="48 1" style="Bgs1InRace" substyle="BgMetalBar"/>
- <!-- Mode buttons -->
- <frame id="Frame_ModeButtons" posn="4.5 -7.75 1">
- <frameinstance posn="0" modelid="FrameModel_ModeButton" id="Frame_ModeButtonBuddies"/>
- <frameinstance posn="6" modelid="FrameModel_ModeButton" id="Frame_ModeButtonGroup"/>
- <frameinstance posn="12" modelid="FrameModel_ModeButton" id="Frame_ModeButtonRequests"/>
- <!-- <frameinstance posn="18" modelid="FrameModel_ModeButton" id="Frame_ModeButtonGlobal"/> -->
- <frameinstance posn="33" modelid="FrameModel_ModeButton" id="Frame_ModeButtonMailbox"/>
- <frameinstance posn="39" modelid="FrameModel_ModeButton" id="Frame_ModeButtonSettings"/>
- </frame>
- <!-- User own Slot -->
- <frameinstance posn="2 -10.75 1" modelid="FrameModel_BuddySlot" id="Frame_LocalUserSlot"/>
- <!-- Buddies Slots -->
- <frame id="Frame_BuddiesSlots" posn="2 -18.75 1">
- <frameinstance posn="0 0" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#0"/>
- <frameinstance posn="0 -8" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#1"/>
- <frameinstance posn="0 -16" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#2"/>
- <frameinstance posn="0 -24" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#3"/>
- <frameinstance posn="0 -32" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#4"/>
- <frameinstance posn="0 -40" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#5"/>
- <frameinstance posn="0 -48" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#6"/>
- <frameinstance posn="0 -56" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#7"/>
- <frameinstance posn="0 -64" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#8"/>
- <frameinstance posn="0 -72" modelid="FrameModel_BuddySlot" id="Frame_BuddySlot#9"/>
- </frame>
- <!-- Buddy inviting -->
- <frame posn="2 -10.75 1" id="Frame_BuddyInviteCard" hidden="1">
- <quad posn="0 -.25" sizen="44 7.5" bgcolor="000" opacity=".125"/>
- <label posn="1 -2.25 1" sizen="48.5 3" scale=".75" valign="center2" textsize="1" textcolor="FFF" text="Add player to buddies list:"/>
- <entry posn="1 -5.5 1" sizen="38 3.5" valign="center2" textsize="1" textcolor="FFF" id="Entry_InvitePlayerInput" ScriptEvents="1"/>
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_InvitePlayerButton" ScriptEvents="1" hidden="1"/>
- </frame>
- <!-- Buddy searching -->
- <frame posn="2 -10.75 1" id="Frame_SearchModeCard" hidden="1">
- <quad posn="0 -.25" sizen="44 7.5" bgcolor="000" opacity=".125"/>
- <label posn="1 -2.25 1" sizen="48.5 3" scale=".75" valign="center2" textsize="1" textcolor="FFF" text="Search for a player:"/>
- <entry posn="1 -5.5 1" sizen="38 3.5" valign="center2" textsize="1" textcolor="FFF" id="Entry_SearchModeInput" ScriptEvents="1"/>
- <quad posn="41.5 -4 1" sizen="3.5 3.5" halign="center" valign="center" class="focus-1 valid-1" id="Quad_SearchModeClose" ScriptEvents="1"/>
- </frame>
- <!-- Page switch -->
- <frame id="Frame_PageSwitch" posn="24 -101.5 1">
- <quad posn="-8 0 1" sizen="5 5" halign="center" valign="center" style="Icons64x64_1" substyle="ArrowPrev" id="Quad_PrevBuddiesPage" ScriptEvents="1"/>
- <label halign="center" valign="center2" style="TextValueSmallSm" textsize="1" id="Label_PageSwitchCounter"/>
- <quad posn="8 0 1" sizen="5 5" halign="center" valign="center" style="Icons64x64_1" substyle="ArrowNext" id="Quad_NextBuddiesPage" ScriptEvents="1"/>
- <quad posn="-8" sizen="5 5" halign="center" valign="center" style="Icons64x64_1" substyle="ArrowDisabled"/>
- <quad posn="8" sizen="5 5" halign="center" valign="center" style="Icons64x64_1" substyle="ArrowDisabled"/>
- </frame>
- <!-- Settings tab -->
- <frame id="Frame_SettingsMenu" posn="2 -14 1" hidden="1">
- <label posn="0 0" valign="center2" style="TextButtonNav" textsize="1" textcolor="FFF" text="Settings" translate="1"/>
- <label posn="0 -5" valign="center2" textsize="1" textcolor="FFF" text="Status with current activity"/>
- <quad posn="40.5 -5" class="Check" id="Quad_CheckUseDynamicStatus" ScriptEvents="1"/>
- <label posn="0 -10" valign="center2" textsize="1" textcolor="FFF" text="Automatically format links"/>
- <quad posn="40.5 -10" class="Check" id="Quad_CheckUseLinksPhrasing" ScriptEvents="1"/>
- <label posn="0 -15" valign="center2" textsize="1" textcolor="FFF" text="Group password"/>
- <entry posn="44 -15" sizen="16 3.5" halign="right" valign="center2" textsize="1" textemboss="1" textcolor="FFF" textformat="newpassword" id="Entry_GroupChatPassword" ScriptEvents="1"/>
- <label posn="0 -20" valign="center2" textsize="1" textcolor="FFF" text="Enable Global Chat"/>
- <quad posn="40.5 -20" class="Check" id="Quad_CheckEnableGlobalChat" ScriptEvents="1"/>
- <label posn="0 -25" valign="center2" textsize="1" textcolor="FFF" text="Notice on new message"/>
- <quad posn="40.5 -25" class="Check" id="Quad_CheckNoticeOnNewMessage" ScriptEvents="1"/>
- <label posn="0 -30" valign="center2" textsize="1" textcolor="FFF" text="Notice on new connection"/>
- <quad posn="40.5 -30" class="Check" id="Quad_CheckNoticeOnConnection" ScriptEvents="1"/>
- </frame>
- <label
- posn="24 -75.5 1" halign="center" style="CardButtonMediumL" text="Download update" id="Label_ButtonUpdate" hidden="1"
- url="https://raw.githubusercontent.com/domino54/title-packs/master/Plugins/Evidence.Script.txt"
- />
- <textedit posn="2 -84.5 1" sizen="44 18" textsize="1" textcolor="FFF" id="TextEdit_PasteBin"/>
- </frame>
- <!-- Messaging window -->
- <frame id="Frame_MessengerWindow" posn="164">
- <!-- Background images -->
- <quad posn="-.25" sizen="137 106" image="file://Media/Manialinks/Common/background3.png" ScriptEvents="1"/>
- <quad posn="0 0 -1" sizen="137 104" style="Bgs1" substyle="BgDialogBlur" opacity="0"/>
- <quad posn="-3 3 1" sizen="142 7.5" style="Bgs1InRace" substyle="BgGlow2"/>
- <quad posn="0 -104.5 1" sizen="136 1" style="Bgs1InRace" substyle="BgMetalBar"/>
- <!-- User information -->
- <frame id="Frame_MessengerBuddyInfo" posn="2 .25 1">
- <label posn="0 -4.5 1" sizen="60 4" valign="center2" id="Label_MessengerBuddyName"/>
- <quad posn="-.9 -8.5 1" sizen="4.5 4.5" valign="center" style="Icons64x64_1" substyle="ClipPause" id="Quad_MessengerBuddyPresence" ScriptEvents="1"/>
- <label posn="4 -8.5 1" sizen="60 3" valign="center2" textsize="1" textemboss="1" textcolor="FC0" maxline="1" id="Label_MessengerBuddyStatus"/>
- <entry posn="4 -8.5 1" sizen="60 3.5" valign="center2" textsize="1" textemboss="1" textcolor="FC0" maxline="1" id="Entry_MessengerStatusInput" ScriptEvents="1" hidden="1"/>
- </frame>
- <!-- User actions -->
- <frame id="Frame_MessengerBuddyActions" posn="134.5 -6.1 1">
- <!-- Server name and join button -->
- <quad posn="-6 0 1" sizen="6 6" valign="center" class="focus-1 valid-1" id="Quad_MessengerBuddyJoin" ScriptEvents="1" hidden="1"/>
- <quad posn="-6" sizen="6 6" valign="center" image="{{{C_ImgBase}}}buddy-join-off.dds"/>
- <label posn="-6.5 1.75" sizen="60 3" halign="right" valign="center2" textsize="1" textcolor="FFF" textemboss="1" id="Label_MessengerBuddyServer"/>
- <!-- Action buttons -->
- <quad posn="-15 -1.75" sizen="4 4" valign="center" class="focus-1 valid-1" id="Quad_MessengerBuddyRemove" ScriptEvents="1"/>
- <quad posn="-10.5 -1.75" sizen="4 4" valign="center" style="Icons64x64_1" substyle="Outbox" id="Quad_MessengerBuddyMail" ScriptEvents="1"/>
- <!-- Buddy login -->
- <label posn="-15.5 -1.75" sizen="30 3" halign="right" valign="center2" textsize="1" textemboss="1" textcolor="AAA" id="Label_MessengerBuddyLogin"/>
- </frame>
- <!-- Messages models -->
- <frame id="Frame_MessagesSlots" posn="2 -98.75 1" clip="1" clipposn="66 42.75" clipsizen="132 87.5">
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#0" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#1" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#2" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#3" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#4" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#5" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#6" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#7" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#8" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#9" hidden="1"/>
- <frameinstance modelid="FrameModel_MessageSlot" id="Frame_MessageSlot#10" hidden="1"/>
- <quad posn="6 2.25" sizen="3.5 3.5" halign="center" valign="center" style="Icons64x64_1" substyle="Check" styleselected="1" id="Quad_SeenMessage" hidden="1"/>
- </frame>
- <frame id="Frame_BottomControls" posn="0 -101.5 1">
- <!-- Message entry -->
- <entry posn="2" sizen="122 4" valign="center2" textsize="1" textcolor="FFF" id="Entry_MessageSubmit" ScriptEvents="1"/>
- <!-- Control buttons -->
- <quad posn="125 0 1" sizen="5 5" valign="center" style="Icons64x64_1" substyle="ArrowUp" id="Quad_MessagesScrollUp" ScriptEvents="1" hidden="1"/>
- <quad posn="130 0 1" sizen="5 5" valign="center" style="Icons64x64_1" substyle="ArrowDown" id="Quad_MessagesScrollDown" ScriptEvents="1" hidden="1"/>
- <quad posn="125" sizen="5 5" valign="center" style="Icons64x64_1" substyle="ArrowDisabled"/>
- <quad posn="130" sizen="5 5" valign="center" style="Icons64x64_1" substyle="ArrowDisabled"/>
- </frame>
- </frame>
- </frame>
- </frame>
- <script><!--
- /**
- * EVIDENCE by domino54
- * Interface manialink
- */
- #Include "MathLib" as ML
- #Include "TextLib" as TL
- #Const C_WidgetAnimDuration 200. ///< Duration of the show/hide animations
- #Const C_EvidenceFramePosY 84. ///< Position of the Evidence window when visible
- #Const C_EvidenceFramePosHide 120. ///< Position offset when Evidence window is hidden
- #Const C_MessengerFramePosX 24. ///< Position of the Messenger window when visible
- #Const C_MessengerFramePosHide 140. ///< Position offset when Messenger window is hidden
- #Const C_MaxMessagesInHistory 32 ///< Maximum amount of messages stored per conversation
- /// Update checker
- #Const C_UpdateCheckInterval 1800000
- #Const C_UpdateCheckAddress "https://raw.githubusercontent.com/domino54/title-packs/master/evidence-version.txt"
- /// Available modes in the Evidence widget (with exception of Mailbox)
- #Const C_ChatWidgetModes ["Buddies", "Group", "Requests", /* "Global", */ "Mailbox", "Settings"]
- /// Default statuses for users presences
- #Const C_UserPresenceStatus [_("Offline"), _("Available"), _("Away"), _("Busy"), _("Available"), _("Away")]
- /// Global Chat connection status
- #Const C_GlobalChatConnectionStatus [0 => _("Offline"), 1 => _("Connected"), 3 => _("|Broadcasting|Connecting...")]
- /// Colors of the users presences
- #Const C_UserPresenceColors [
- <.2, .4, .5>, ///< Offline
- <.3, 1., .3>, ///< Available
- <1., 1., 0.>, ///< Away
- <1., .3, .3>, ///< Busy
- <.3, 1., .3>, ///< Available Evidence (former Wanna talk!)
- <1., 1., 0.> ///< Away Evidence (former Snooze)
- ]
- /// Opacity of the mode buttons
- #Const C_ModeButtonsOpacity [
- False => [ ///< Disabled
- False => .25, ///< Off
- True => .625 ///< Focus
- ],
- True => [ ///< Selected
- False => .875, ///< Off
- True => 1. ///< Focus
- ]
- ]
- /// Colors of the buddies cards
- #Const C_BuddySlotBgColors [
- False => [ ///< Disabled
- False => <0., 0., 0.>, ///< Off
- True => <.3, .3, .3> ///< Focus
- ],
- True => [ ///< Selected
- False => <.6, .6, .6>, ///< Off
- True => <.9, .9, .9> ///< Focus
- ]
- ]
- /// Mute button images
- #Const C_SlotMuteButtonImages [
- False => [ ///< Not muted
- False => "{{{C_ImgBase}}}buddy-ally-on.dds",
- True => "{{{C_ImgBase}}}buddy-ally-on-focus.dds"
- ],
- True => [ ///< Muted
- False => "{{{C_ImgBase}}}buddy-ally-off.dds",
- True => "{{{C_ImgBase}}}buddy-ally-focus.dds"
- ]
- ]
- /// URLs of the mode buttons images
- #Const C_ModeButtonsImagesURLs [
- "Buddies" => "http://i.imgur.com/zWESBiR.png",
- "Group" => "http://i.imgur.com/qFKByDl.png",
- "Requests" => "http://i.imgur.com/TIAbhB7.png",
- "Global" => "http://i.imgur.com/MXfIHAs.png",
- "Mailbox" => "http://i.imgur.com/ULIzuFa.png",
- "Settings" => "http://i.imgur.com/6ydip4k.png"
- ]
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- ***Main***
- ***
- // ---------------------------------- //
- // Load interface elements
- declare Frame_EvidencePlugin <=> (Page.GetFirstChild("Frame_EvidencePlugin") as CMlFrame);
- declare Frame_MessengerWindow <=> (Page.GetFirstChild("Frame_MessengerWindow") as CMlFrame);
- /// Local user Slot
- declare Frame_LocalUserSlot <=> (Page.GetFirstChild("Frame_LocalUserSlot") as CMlFrame);
- declare Quad_LocalUserBgCard <=> (Frame_LocalUserSlot.GetFirstChild("Quad_BuddySlotBgCard") as CMlQuad);
- declare Label_LocalUserBgName <=> (Frame_LocalUserSlot.GetFirstChild("Label_BuddySlotName") as CMlLabel);
- declare Label_LocalUserStatus <=> (Frame_LocalUserSlot.GetFirstChild("Label_BuddySlotStatus") as CMlLabel);
- declare Quad_LocalUserPresence <=> (Frame_LocalUserSlot.GetFirstChild("Quad_BuddySlotPresence") as CMlQuad);
- declare Quad_LocalUserGlow <=> (Frame_LocalUserSlot.GetFirstChild("Quad_BuddySlotGlow") as CMlQuad);
- declare Quad_LocalUserSearch <=> (Frame_LocalUserSlot.GetFirstChild("Quad_BuddySlotBtnSearch") as CMlQuad);
- /// Player inviting
- declare Frame_BuddyInviteCard <=> (Page.GetFirstChild("Frame_BuddyInviteCard") as CMlFrame);
- declare Entry_InvitePlayerInput <=> (Page.GetFirstChild("Entry_InvitePlayerInput") as CMlEntry);
- declare Quad_InvitePlayerButton <=> (Page.GetFirstChild("Quad_InvitePlayerButton") as CMlQuad);
- /// Player search
- declare Frame_SearchModeCard <=> (Page.GetFirstChild("Frame_SearchModeCard") as CMlFrame);
- declare Entry_SearchModeInput <=> (Page.GetFirstChild("Entry_SearchModeInput") as CMlEntry);
- /// Buddies list page switch
- declare Frame_PageSwitch <=> (Page.GetFirstChild("Frame_PageSwitch") as CMlFrame);
- declare Quad_PrevBuddiesPage <=> (Page.GetFirstChild("Quad_PrevBuddiesPage") as CMlQuad);
- declare Quad_NextBuddiesPage <=> (Page.GetFirstChild("Quad_NextBuddiesPage") as CMlQuad);
- declare Label_PageSwitchCounter <=> (Page.GetFirstChild("Label_PageSwitchCounter") as CMlLabel);
- /// Messenger scrolling
- declare Quad_MessagesScrollUp <=> (Page.GetFirstChild("Quad_MessagesScrollUp") as CMlQuad);
- declare Quad_MessagesScrollDown <=> (Page.GetFirstChild("Quad_MessagesScrollDown") as CMlQuad);
- /// Messanger buddy information
- declare Label_MessengerBuddyName <=> (Page.GetFirstChild("Label_MessengerBuddyName") as CMlLabel);
- declare Quad_MessengerBuddyPresence <=> (Page.GetFirstChild("Quad_MessengerBuddyPresence") as CMlQuad);
- declare Label_MessengerBuddyStatus <=> (Page.GetFirstChild("Label_MessengerBuddyStatus") as CMlLabel);
- declare Entry_MessengerStatusInput <=> (Page.GetFirstChild("Entry_MessengerStatusInput") as CMlEntry);
- /// Messenger buddy actions
- declare Frame_MessengerBuddyActions <=> (Page.GetFirstChild("Frame_MessengerBuddyActions") as CMlFrame);
- declare Label_MessengerBuddyLogin <=> (Page.GetFirstChild("Label_MessengerBuddyLogin") as CMlLabel);
- declare Label_MessengerBuddyServer <=> (Page.GetFirstChild("Label_MessengerBuddyServer") as CMlLabel);
- declare Quad_MessengerBuddyJoin <=> (Page.GetFirstChild("Quad_MessengerBuddyJoin") as CMlQuad);
- declare Quad_MessengerBuddyMail <=> (Page.GetFirstChild("Quad_MessengerBuddyMail") as CMlQuad);
- declare Quad_MessengerBuddyRemove <=> (Page.GetFirstChild("Quad_MessengerBuddyRemove") as CMlQuad);
- declare Quad_SeenMessage <=> (Page.GetFirstChild("Quad_SeenMessage") as CMlQuad);
- /// Settings tab
- declare Frame_SettingsMenu <=> (Page.GetFirstChild("Frame_SettingsMenu") as CMlFrame);
- declare Quad_CheckUseDynamicStatus <=> (Page.GetFirstChild("Quad_CheckUseDynamicStatus") as CMlQuad);
- declare Quad_CheckUseLinksPhrasing <=> (Page.GetFirstChild("Quad_CheckUseLinksPhrasing") as CMlQuad);
- declare Quad_CheckEnableGroupChat <=> (Page.GetFirstChild("Quad_CheckEnableGroupChat") as CMlQuad);
- declare Entry_GroupChatPassword <=> (Page.GetFirstChild("Entry_GroupChatPassword") as CMlEntry);
- declare Quad_CheckEnableGlobalChat <=> (Page.GetFirstChild("Quad_CheckEnableGlobalChat") as CMlQuad);
- declare Quad_CheckNoticeOnNewMessage <=> (Page.GetFirstChild("Quad_CheckNoticeOnNewMessage") as CMlQuad);
- declare Quad_CheckNoticeOnConnection <=> (Page.GetFirstChild("Quad_CheckNoticeOnConnection") as CMlQuad);
- declare Label_ButtonUpdate <=> (Page.GetFirstChild("Label_ButtonUpdate") as CMlLabel);
- declare TextEdit_PasteBin <=> (Page.GetFirstChild("TextEdit_PasteBin") as CMlTextEdit);
- /// Mode buttons
- declare CMlFrame[Text] Frame_ModeButtons;
- foreach (Mode in C_ChatWidgetModes) {
- Frame_ModeButtons[Mode] <=> (Page.GetFirstChild("Frame_ModeButton"^Mode) as CMlFrame);
- declare Quad_ModeButtonIcon <=> (Frame_ModeButtons[Mode].GetFirstChild("Quad_ModeButtonIcon") as CMlQuad);
- Quad_ModeButtonIcon.ImageUrl = C_ModeButtonsImagesURLs[Mode];
- Quad_ModeButtonIcon.DataAttributeSet("mode", Mode);
- }
- /// Buddies list slots
- declare CMlFrame[] Frame_BuddiesSlots;
- for (I, 0, 9) Frame_BuddiesSlots.add((Page.GetFirstChild("Frame_BuddySlot#"^I) as CMlFrame));
- /// Messages slots
- declare CMlFrame[] Frame_MessagesSlots;
- for (I, 0, 10) Frame_MessagesSlots.add((Page.GetFirstChild("Frame_MessageSlot#"^I) as CMlFrame));
- // ---------------------------------- //
- // Persistent settings
- declare persistent Text[][Text] Persistent_Evidence_ChatHistoryBody for Page;
- declare persistent Text[][Text] Persistent_Evidence_ChatHistorySender for Page;
- declare persistent Text[][Text] Persistent_Evidence_ChatHistoryDate for Page;
- declare persistent Integer[Text] Persistent_Evidence_NbUnreadMessages for Page;
- declare persistent Integer Persistent_Evidence_UserTargetPresenceId for Page = 4;
- declare persistent Text Persistent_Evidence_UserCustomStatus for Page;
- declare persistent Text Persistent_Evidence_PasteBin for Page;
- declare persistent Text[] Persistent_Evidence_UsersSeenMessages for Page;
- declare persistent Boolean Persistent_Evidence_UseDynamicStatus for Page = True;
- declare persistent Boolean Persistent_Evidence_UseLinksPhrasing for Page = True;
- declare persistent Text Persistent_Evidence_GroupChatPassword for Page;
- declare persistent Boolean Persistent_Evidence_EnableGlobalChat for Page = True;
- declare persistent Boolean Persistent_Evidence_NoticeOnNewMessage for Page = True;
- declare persistent Boolean Persistent_Evidence_NoticeOnConnection for Page = True;
- if (Persistent_Evidence_UserTargetPresenceId < 3) Persistent_Evidence_UserTargetPresenceId = 4;
- // ---------------------------------- //
- // Plugin script communication
- declare NewReceivedMessages for Page = Text[][]; ///< New messages to proceed
- declare ChatWidgetIsOpen for Page = False; ///< Current chat state
- declare MessengerIsOpen for Page = False; ///< Current messenger state
- declare CurrentWidgetMode for Page = ""; ///< Active widget mode
- declare SelectedConversation for Page = ""; ///< Login of selected buddy for private conversation
- declare LegacyMailsAmount for Page = 0; ///< Amount of messages in classic mailbox
- declare CurrentPluginPresenceId for Page = 4; ///< Current presence Id of the user
- declare CurrentPluginStatusText for Page = ""; ///< Currently displayed status of the user
- declare ManialinkTargetPresence for Page = 4; ///< Requested user presence Id
- declare ManialinkCustomStatus for Page = ""; ///< Custom status specified by user
- declare TotalNbUnreadMessages for Page = 0; ///< Total amount of unread messages
- declare FlashTaskbar for Page = False; ///< Force game to blink taskbar icon
- declare UsersThatSeenMessage for Page = Text[]; ///< Users that just seen message
- /// Settings
- declare UseDynamicStatus for Page = False; ///< User context status setting
- declare UseLinksPhrasing for Page = False; ///< User automatic link formatting setting
- declare GroupChatPassword for Page = ""; ///< Group Chat password
- declare EnableGlobalChat for Page = False; ///< Global Chat usage setting
- declare NoticeOnNewMessage for Page = False; ///< Display notices on new messages
- declare NoticeOnConnection for Page = False; ///< Display notice on buddy connection
- declare GlobalChat_ConnectionStatus for Page = 0;
- /// Update variables
- declare PrevChatWidgetIsOpen = False;
- declare PrevMessengerIsOpen = False;
- declare PrevWidgetMode = "!";
- declare PrevSelectedConversation = "!";
- declare PrevLegacyMailsAmount = -1;
- declare PrevPluginPresenceId = 0;
- declare PrevEntryStatusValue = "!";
- declare PrevGlobalChatConnectionStatus = -1;
- // ---------------------------------- //
- // Plugin buddies data
- declare Text[] BuddiesList_Online for Page; ///< Buddies currently being connected
- declare Text[] BuddiesList_Offline for Page; ///< Buddies currently being offline
- declare Text[] BuddiesList_RequestFrom for Page; ///< Incoming buddies invitations
- declare Text[] BuddiesList_RequestTo for Page; ///< Sent buddies invitations
- declare Text[] BuddiesList_OnServer for Page; ///< Players on current server
- declare Text[] BuddiesList_InGroup for Page; ///< Buddies in the group
- declare Text[] BuddiesList_GlobalList for Page; ///< Buddies available on the global chat
- declare Text[] BuddiesList_MutedUsers for Page; ///< Buddies muted
- declare Text[] BuddiesList_SearchList for Page; ///< List of buddies found in search
- declare Text[] BuddiesList_Evidence for Page; ///< Buddies using Evidence chat
- declare Text[] BuddiesList_ListOnTop for Page; ///< Buddies to be listed on top
- declare Text[] BuddiesList_SortedList for Page; ///< Sorted list of all buddies (online and offline)
- declare Text[] BuddiesList_RequestList for Page; ///< Sorted list of all requests
- declare Text[Text] BuddiesName for Page; ///< Names of the buddies
- declare Integer[Text] BuddiesPresenceId for Page; ///< Presence Ids of the buddies
- declare Text[Text] BuddiesStatus for Page; ///< Statuses of the buddies
- declare Text[Text] BuddiesServerLogin for Page; ///< Login of the servers buddies are on
- declare Boolean[Text] BuddiesIsMuted for Page; ///< True if buddy is muted in Group Chat
- declare Text[Text] BuddiesJoinLink for Page; ///< Links to join buddies servers
- /// Global chat data
- declare Integer[Text] GlobalChat_BuddiesPresenceId for Page;
- declare Text[Text] GlobalChat_BuddiesName for Page;
- declare Text[Text] GlobalChat_BuddiesStatus for Page;
- declare Text[Text] ServersName for Page; ///< Names of the buddies servers
- /// Update variables
- declare PrevBuddiesOnline = -1;
- declare PrevBuddiesOffline = -1;
- declare PrevBuddiesRequestFrom = -1;
- declare PrevBuddiesRequestTo = -1;
- declare PrevBuddiesOnServer = -1;
- declare PrevBuddiesInGroup = -1;
- declare PrevBuddiesGlobalList = -1;
- declare PrevBuddiesMutedUsers = -1;
- declare Text[Text] PrevBuddiesName;
- declare Integer[Text] PrevBuddiesPresenceId;
- declare Text[Text] PrevBuddiesStatus;
- declare Text[Text] PrevBuddiesServerLogin;
- declare Text[Text] PrevGlobalBuddiesName;
- declare Integer[Text] PrevGlobalBuddiesPresenceId;
- // ---------------------------------- //
- // Variables
- declare SortBuddiesList = True; ///< Forces manialink to sort Buddies tab
- declare SortRequestsList = True; ///< Forces manialink to sort Requests tab
- declare UpdateBuddiesList = True; ///< Forces manialink to build buddies list
- declare HighlightModeButton = ""; ///< ID of the mode button to highlight
- declare UpdateModeButtons = True; ///< Update opacity of the mode buttons
- declare HighlightBuddySlot = NullId; ///< ID of the buddy slot to highlight
- declare UpdateSlotsBgSlots = True; ///< Update backgrounds of the buddies slots
- declare UpdateMessagesSlots = 2; ///< Amount of pending messages slots updates
- declare UpdateMessengerInfo = True; ///< Update name and status of the conversation
- declare MessagesOffset = Integer[Text]; ///< Messages scrolling option
- declare NextUpdateCheckout = 0; ///< Time of the next update check
- declare PluginIsOutdated = False;
- declare UpdateCheckRequest = CHttpRequest;
- declare PrevEntrySearchValue = "";
- declare GameIsInFocus = False;
- declare PrevGameIsInFocus = False;
- /// Current and total page number on tabs
- declare Integer[Text] CurrentPage;
- declare Integer[Text] PagesCount;
- foreach (Mode in C_ChatWidgetModes) {
- CurrentPage[Mode] = 1;
- PagesCount[Mode] = 1;
- }
- CurrentPage["Search"] = 1;
- PagesCount["Search"] = 1;
- /// Unread messages amount
- declare UnreadMessagesGroups = ["Buddies", "Group", "Global"];
- declare Integer[Text] NbUnreadMessages;
- declare Integer[Text] PrevNbUnreadMessages;
- foreach (Group in UnreadMessagesGroups) {
- NbUnreadMessages[Group] = 0;
- PrevNbUnreadMessages[Group] = 0;
- }
- // ---------------------------------- //
- // Initialize variables
- ManialinkTargetPresence = Persistent_Evidence_UserTargetPresenceId;
- Entry_MessengerStatusInput.Value = Persistent_Evidence_UserCustomStatus;
- Entry_GroupChatPassword.Value = Persistent_Evidence_GroupChatPassword;
- TextEdit_PasteBin.Value = Persistent_Evidence_PasteBin;
- Quad_LocalUserBgCard.DataAttributeSet("login", LocalUser.Login);
- CurrentWidgetMode = "Buddies";
- // ---------------------------------- //
- // Convert deprecated history onto new one
- declare persistent Text[][][Text] Persistent_Evidence_ChatHistory for Page;
- if (Persistent_Evidence_ChatHistory.count > 0) {
- foreach (ConversationLogin => Messages in Persistent_Evidence_ChatHistory) {
- if (!Persistent_Evidence_ChatHistorySender.existskey(ConversationLogin))
- Persistent_Evidence_ChatHistorySender[ConversationLogin] = Text[];
- if (!Persistent_Evidence_ChatHistoryBody.existskey(ConversationLogin))
- Persistent_Evidence_ChatHistoryBody[ConversationLogin] = Text[];
- if (!Persistent_Evidence_ChatHistoryDate.existskey(ConversationLogin))
- Persistent_Evidence_ChatHistoryDate[ConversationLogin] = Text[];
- foreach (MessageData in Messages) {
- Persistent_Evidence_ChatHistorySender[ConversationLogin].add(MessageData[0]);
- Persistent_Evidence_ChatHistoryBody[ConversationLogin].add(MessageData[1]);
- Persistent_Evidence_ChatHistoryDate[ConversationLogin].add(MessageData[2]);
- }
- }
- Persistent_Evidence_ChatHistory.clear();
- }
- ***
- // ---------------------------------- //
- // Yield
- // ---------------------------------- //
- ***Yield***
- ***
- // ---------------------------------- //
- // Manage events
- foreach (Event in PendingEvents) {
- // ---------------------------------- //
- // Keyboard button press
- if (Event.Type == CMlEvent::Type::KeyPress) {
- // ---------------------------------- //
- // Change Evidence visibility
- if (Event.KeyName == "F7") ChatWidgetIsOpen = !ChatWidgetIsOpen;
- }
- // ---------------------------------- //
- // Mouse click
- else if (Event.Type == CMlEvent::Type::MouseClick) {
- // ---------------------------------- //
- // Change current widget mode
- if (Event.ControlId == "Quad_ModeButtonIcon") {
- declare NewMode = Event.Control.DataAttributeGet("mode");
- if (NewMode == "Mailbox") OpenLink("#mailto=", ::LinkType::ManialinkBrowser);
- else CurrentWidgetMode = NewMode;
- }
- // ---------------------------------- //
- // Change current widget mode
- else if (Event.ControlId == "Quad_BuddySlotBgCard") {
- // Go to the Group mode
- if (Event.Control == Quad_LocalUserBgCard) CurrentWidgetMode = "Group";
- // ---------------------------------- //
- // Select buddy
- else if (CurrentWidgetMode != "Global") {
- // ---------------------------------- //
- // Open buddy conversation
- declare BuddyLogin = Event.Control.DataAttributeGet("login");
- if (SelectedConversation != BuddyLogin) {
- SelectedConversation = BuddyLogin;
- if (CurrentWidgetMode == "Group") CurrentWidgetMode = "Buddies";
- UpdateMessagesSlots = 2;
- // ---------------------------------- //
- // Close search mode
- if (Frame_SearchModeCard.Visible) {
- Frame_SearchModeCard.Hide();
- Entry_SearchModeInput.Value = "";
- }
- }
- // ---------------------------------- //
- // Hide messenger
- else SelectedConversation = "";
- }
- UpdateSlotsBgSlots = True;
- }
- // ---------------------------------- //
- // Buddies list previous page button
- else if (Event.ControlId == "Quad_PrevBuddiesPage") {
- declare Mode = CurrentWidgetMode;
- if (Frame_SearchModeCard.Visible) Mode = "Search";
- if (CurrentPage[Mode] > 1) CurrentPage[Mode] -= 1;
- UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Buddies list next page button
- else if (Event.ControlId == "Quad_NextBuddiesPage") {
- declare Mode = CurrentWidgetMode;
- if (Frame_SearchModeCard.Visible) Mode = "Search";
- if (CurrentPage[Mode] < PagesCount[Mode]) CurrentPage[Mode] += 1;
- UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Scroll messages up
- else if (Event.ControlId == "Quad_MessagesScrollUp") {
- declare Text BuddyLogin;
- switch (CurrentWidgetMode) {
- case "Group" : BuddyLogin = "*group*";
- case "Global" : BuddyLogin = "*global*";
- default : BuddyLogin = SelectedConversation;
- }
- if (!MessagesOffset.existskey(BuddyLogin)) MessagesOffset[BuddyLogin] = 0;
- MessagesOffset[BuddyLogin] += 1;
- UpdateMessagesSlots = 2;
- }
- // ---------------------------------- //
- // Scroll messages down
- else if (Event.ControlId == "Quad_MessagesScrollDown") {
- declare Text BuddyLogin;
- switch (CurrentWidgetMode) {
- case "Group" : BuddyLogin = "*group*";
- case "Global" : BuddyLogin = "*global*";
- default : BuddyLogin = SelectedConversation;
- }
- if (!MessagesOffset.existskey(BuddyLogin)) MessagesOffset[BuddyLogin] = 0;
- MessagesOffset[BuddyLogin] -= 1;
- UpdateMessagesSlots = 2;
- }
- // ---------------------------------- //
- // Send buddy invitation
- else if (Event.ControlId == "Quad_InvitePlayerButton") {
- SendCustomEvent("AddBuddy", [Entry_InvitePlayerInput.Value]);
- Entry_InvitePlayerInput.Value = "";
- }
- // ---------------------------------- //
- // Accept buddy request
- else if (Event.ControlId == "Quad_BuddySlotBtnAdd") {
- declare Login = Event.Control.DataAttributeGet("login");
- if (Login != "") SendCustomEvent("BuddyAccept", [Login]);
- }
- // ---------------------------------- //
- // Deny / cancel buddy request
- else if (Event.ControlId == "Quad_BuddySlotBtnDeny") {
- declare Login = Event.Control.DataAttributeGet("login");
- if (Login != "") SendCustomEvent("BuddyDeny", [Login]);
- }
- // ---------------------------------- //
- // Add buddy from server
- else if (Event.ControlId == "Quad_BuddySlotBtnPlus") {
- declare Login = Event.Control.DataAttributeGet("login");
- if (Login != "") SendCustomEvent("AddBuddy", [Login]);
- }
- // ---------------------------------- //
- // Enter the search mode
- else if (Event.ControlId == "Quad_BuddySlotBtnSearch") {
- Frame_SearchModeCard.Show();
- Entry_SearchModeInput.StartEdition();
- PrevWidgetMode = "";
- }
- // ---------------------------------- //
- // Leave search mode
- else if (Event.ControlId == "Quad_SearchModeClose") {
- Frame_SearchModeCard.Hide();
- Entry_SearchModeInput.Value = "";
- PrevWidgetMode = "";
- }
- // ---------------------------------- //
- // Cycle through available presences
- else if (Event.ControlId == "Quad_MessengerBuddyPresence") {
- if (CurrentWidgetMode == "Group") {
- ManialinkTargetPresence += 1;
- if (ManialinkTargetPresence > 5) ManialinkTargetPresence = 3;
- Persistent_Evidence_UserTargetPresenceId = ManialinkTargetPresence;
- }
- }
- // ---------------------------------- //
- // Send mail to specified buddy
- else if (Event.ControlId == "Quad_MessengerBuddyMail") {
- declare BuddyLogin = Event.Control.DataAttributeGet("login");
- if (BuddyLogin != "") OpenLink("#mailto="^BuddyLogin, ::LinkType::ManialinkBrowser);
- }
- // ---------------------------------- //
- // Remove buddy
- else if (Event.ControlId == "Quad_MessengerBuddyRemove") {
- declare Login = Event.Control.DataAttributeGet("login");
- if (Login != "") SendCustomEvent("RemoveBuddy", [Login]);
- SelectedConversation = "";
- }
- // ---------------------------------- //
- // Copy message content buttons
- else if (Event.ControlId == "Quad_MessageSlotBtnCopy") {
- declare ClipboardContents = TL::StripFormatting(Event.Control.DataAttributeGet("clipboard"));
- if (ClipboardContents != "") SendCustomEvent("SetClipboard", [ClipboardContents]);
- }
- // ---------------------------------- //
- // Open manialink
- if (Event.Control.DataAttributeExists("manialink")) {
- declare ManialinkCode = Event.Control.DataAttributeGet("manialink");
- if (ManialinkCode != "") {
- OpenLink(ManialinkCode, ::LinkType::ManialinkBrowser);
- ChatWidgetIsOpen = False;
- }
- }
- // ---------------------------------- //
- // Send command
- if (Event.Control.DataAttributeExists("command")) {
- declare Command = Event.Control.DataAttributeGet("command");
- if (Command != "") SendCustomEvent("SendMessage", ["*group*", Command]);
- }
- // ---------------------------------- //
- // Change Evidence settings
- if (Event.Control.HasClass("Check")) {
- switch (Event.ControlId) {
- case "Quad_CheckUseDynamicStatus" : Persistent_Evidence_UseDynamicStatus = !Persistent_Evidence_UseDynamicStatus;
- case "Quad_CheckUseLinksPhrasing" : Persistent_Evidence_UseLinksPhrasing = !Persistent_Evidence_UseLinksPhrasing;
- case "Quad_CheckEnableGlobalChat" : Persistent_Evidence_EnableGlobalChat = !Persistent_Evidence_EnableGlobalChat;
- case "Quad_CheckNoticeOnNewMessage" : Persistent_Evidence_NoticeOnNewMessage = !Persistent_Evidence_NoticeOnNewMessage;
- case "Quad_CheckNoticeOnConnection" : Persistent_Evidence_NoticeOnConnection = !Persistent_Evidence_NoticeOnConnection;
- }
- }
- // ---------------------------------- //
- // Play sounds
- if (Event.Control.HasClass("valid-0")) Audio.PlaySoundEvent(CAudioManager::ELibSound::Valid, 0, 0.);
- if (Event.Control.HasClass("valid-1")) Audio.PlaySoundEvent(CAudioManager::ELibSound::Valid, 1, 0.);
- }
- // ---------------------------------- //
- // Mouse hover
- else if (Event.Type == CMlEvent::Type::MouseOver) {
- // ---------------------------------- //
- // Highlight mode buttons
- if (Event.ControlId == "Quad_ModeButtonIcon") {
- HighlightModeButton = Event.Control.DataAttributeGet("mode");
- UpdateModeButtons = True;
- }
- // ---------------------------------- //
- // Highlight buddy slot
- else if (Event.ControlId == "Quad_BuddySlotBgCard") {
- HighlightBuddySlot = Event.Control.Id;
- UpdateSlotsBgSlots = True;
- }
- // ---------------------------------- //
- // Play sounds
- if (Event.Control.HasClass("focus-1")) Audio.PlaySoundEvent(CAudioManager::ELibSound::Focus, 1, 0.);
- if (Event.Control.HasClass("focus-2")) Audio.PlaySoundEvent(CAudioManager::ELibSound::Focus, 2, 0.);
- }
- // ---------------------------------- //
- // Mouse hover end
- else if (Event.Type == CMlEvent::Type::MouseOut) {
- // ---------------------------------- //
- // Highlight mode buttons
- if (Event.ControlId == "Quad_ModeButtonIcon") {
- HighlightModeButton = "";
- UpdateModeButtons = True;
- }
- // ---------------------------------- //
- // Highlight buddy slot
- else if (Event.ControlId == "Quad_BuddySlotBgCard") {
- HighlightBuddySlot = NullId;
- UpdateSlotsBgSlots = True;
- }
- }
- // ---------------------------------- //
- // Entry submission
- else if (Event.Type == CMlEvent::Type::EntrySubmit) {
- declare Entry <=> (Event.Control as CMlEntry);
- // ---------------------------------- //
- // Message input
- if (Event.ControlId == "Entry_MessageSubmit") {
- if (Entry.Value != "" && Entry.Value != "$") {
- // ---------------------------------- //
- // Select conversation
- declare Text TargetConversation;
- switch (CurrentWidgetMode) {
- case "Group" : TargetConversation = "*group*";
- case "Global" : TargetConversation = "*global*";
- default : TargetConversation = SelectedConversation;
- }
- // Send message
- if (TargetConversation != "") {
- declare FormattedMessage = FormatMessage(Entry.Value);
- SendCustomEvent("SendMessage", [TargetConversation, FormattedMessage]);
- if (TargetConversation != "*global*" && TargetConversation != "*group*" && TL::SubString(Entry.Value, 0, 1) != "/")
- NewReceivedMessages.add([TargetConversation, LocalUser.Login, FormattedMessage]);
- Entry.Value = "";
- // ---------------------------------- //
- // Reset laste message read state
- if (Persistent_Evidence_UsersSeenMessages.exists(TargetConversation)) {
- declare Removed = Persistent_Evidence_UsersSeenMessages.remove(TargetConversation);
- }
- }
- }
- Entry.StartEdition();
- }
- // ---------------------------------- //
- // Send buddy invitation
- else if (Event.ControlId == "Entry_InvitePlayerInput") {
- SendCustomEvent("AddBuddy", [Entry.Value]);
- Entry.Value = "";
- }
- }
- }
- GameIsInFocus = <MouseX, MouseY> != <-1000., -1000.>;
- // ---------------------------------- //
- // New messages to display
- while (NewReceivedMessages.count > 0) {
- declare MessageData = NewReceivedMessages[0];
- declare Removed = NewReceivedMessages.removekey(0);
- // ---------------------------------- //
- // Get new message data
- if (MessageData.count >= 3) {
- declare ConversationLogin = MessageData[0];
- declare SenderLogin = MessageData[1];
- declare MessageBody = FormatMessage(MessageData[2]);
- // Initialize conversation history array if empty
- if (
- !Persistent_Evidence_ChatHistoryBody.existskey(ConversationLogin) ||
- !Persistent_Evidence_ChatHistorySender.existskey(ConversationLogin) ||
- !Persistent_Evidence_ChatHistoryDate.existskey(ConversationLogin)
- ) {
- Persistent_Evidence_ChatHistoryBody[ConversationLogin] = Text[];
- Persistent_Evidence_ChatHistorySender[ConversationLogin] = Text[];
- Persistent_Evidence_ChatHistoryDate[ConversationLogin] = Text[];
- }
- // ---------------------------------- //
- // Look up for images
- declare MessageIsImage = TL::SubText(MessageBody, 0, 6) == "image:";
- if (!MessageIsImage) {
- declare ReceivedImages = FindImages(MessageBody);
- foreach (URL in ReceivedImages) {
- // Remove images links from message
- MessageBody = TL::Replace(MessageBody, "$<$FA3$l"^URL^"$>", "");
- // Re-send message
- NewReceivedMessages.add([ConversationLogin, SenderLogin, "image:"^URL]);
- }
- }
- if (MessageBody == "") continue;
- // ---------------------------------- //
- // Attach message to previous one if sender is the same
- declare PreviousMessageId = Persistent_Evidence_ChatHistoryBody[ConversationLogin].count - 1;
- if (
- !MessageIsImage &&
- Persistent_Evidence_ChatHistorySender[ConversationLogin].existskey(PreviousMessageId) &&
- Persistent_Evidence_ChatHistorySender[ConversationLogin][PreviousMessageId] == SenderLogin &&
- TL::SubText(Persistent_Evidence_ChatHistoryBody[ConversationLogin][PreviousMessageId], 0, 6) != "image:"
- ) {
- Persistent_Evidence_ChatHistoryBody[ConversationLogin][PreviousMessageId] ^= "\n$z"^MessageBody;
- Persistent_Evidence_ChatHistoryDate[ConversationLogin][PreviousMessageId] = CurrentLocalDateText;
- }
- // ---------------------------------- //
- // Save new message in history
- else {
- Persistent_Evidence_ChatHistoryBody[ConversationLogin].add(MessageBody);
- Persistent_Evidence_ChatHistorySender[ConversationLogin].add(SenderLogin);
- Persistent_Evidence_ChatHistoryDate[ConversationLogin].add(CurrentLocalDateText);
- }
- // ---------------------------------- //
- // Remove oldest messages from history
- declare SavedMessagesAmount = Persistent_Evidence_ChatHistoryBody[ConversationLogin].count;
- if (SavedMessagesAmount > C_MaxMessagesInHistory) for (I, 1, SavedMessagesAmount - C_MaxMessagesInHistory) {
- declare Boolean Removed;
- Removed = Persistent_Evidence_ChatHistoryBody[ConversationLogin].removekey(0);
- Removed = Persistent_Evidence_ChatHistorySender[ConversationLogin].removekey(0);
- Removed = Persistent_Evidence_ChatHistoryDate[ConversationLogin].removekey(0);
- }
- // ---------------------------------- //
- // Move buddy to the top of the list
- if (!BuddiesList_ListOnTop.exists(ConversationLogin)) {
- BuddiesList_ListOnTop.add(ConversationLogin);
- SortBuddiesList = True;
- }
- // ---------------------------------- //
- // Update messages slots manialink
- declare SpecialMessageModes = ["Group" => "*group*", "Global" => "*global*"];
- if (
- (ConversationLogin == SelectedConversation && !SpecialMessageModes.exists(CurrentWidgetMode)) ||
- (SpecialMessageModes.existskey(CurrentWidgetMode) && SpecialMessageModes[CurrentWidgetMode] == ConversationLogin)
- )
- UpdateMessagesSlots = 2;
- // ---------------------------------- //
- // Check if user should receive notification
- declare NotifyUser = False;
- switch (ConversationLogin) {
- case "*group*" : NotifyUser = (CurrentWidgetMode != "Group");
- case "*global*" : NotifyUser = (CurrentWidgetMode != "Global");
- default : NotifyUser = (SelectedConversation != ConversationLogin || SpecialMessageModes.existskey(CurrentWidgetMode));
- }
- if (SenderLogin != LocalUser.Login && (NotifyUser || !ChatWidgetIsOpen || !GameIsInFocus)) {
- // ---------------------------------- //
- // Increase amount of unread messages
- if (!Persistent_Evidence_NbUnreadMessages.existskey(ConversationLogin))
- Persistent_Evidence_NbUnreadMessages[ConversationLogin] = 0;
- Persistent_Evidence_NbUnreadMessages[ConversationLogin] += 1;
- // ---------------------------------- //
- // Play notification sound
- if (CurrentPluginPresenceId != 3 && ConversationLogin != "*global*")
- Audio.PlaySoundEvent(CAudioManager::ELibSound::Alert, 1, 0.);
- // ---------------------------------- //
- // Display notification
- if (NoticeOnNewMessage) SendCustomEvent("ShowMessageNotice", [SenderLogin, MessageBody]);
- }
- else if (SenderLogin != LocalUser.Login) SendCustomEvent("SeenMessage", [SenderLogin]);
- // ---------------------------------- //
- // Flash taskbar
- if (SenderLogin != LocalUser.Login && ConversationLogin != "*global*")
- FlashTaskbar = True;
- }
- }
- // ---------------------------------- //
- // Get users that seen the message
- while (UsersThatSeenMessage.count > 0) {
- if (!Persistent_Evidence_UsersSeenMessages.exists(UsersThatSeenMessage[0])) {
- Persistent_Evidence_UsersSeenMessages.add(UsersThatSeenMessage[0]);
- if (UsersThatSeenMessage[0] == SelectedConversation) UpdateMessagesSlots = 2;
- }
- declare Removed = UsersThatSeenMessage.removekey(0);
- }
- // ---------------------------------- //
- // Update messages on focus change
- if (PrevGameIsInFocus != GameIsInFocus) {
- PrevGameIsInFocus = GameIsInFocus;
- if (
- GameIsInFocus &&
- Persistent_Evidence_NbUnreadMessages.existskey(SelectedConversation) &&
- Persistent_Evidence_NbUnreadMessages[SelectedConversation] > 0
- ) {
- UpdateMessagesSlots = 2;
- }
- }
- // ---------------------------------- //
- // Update unread messages amount
- NbUnreadMessages["Buddies"] = 0;
- foreach (Login => Amount in Persistent_Evidence_NbUnreadMessages) {
- switch (Login) {
- case "*group*" : NbUnreadMessages["Group"] = Amount;
- case "*global*" : NbUnreadMessages["Global"] = Amount;
- default : NbUnreadMessages["Buddies"] += Amount;
- }
- }
- // ---------------------------------- //
- // Set mode buttons notifications amount
- foreach (Group in UnreadMessagesGroups) {
- if (PrevNbUnreadMessages[Group] != NbUnreadMessages[Group]) {
- PrevNbUnreadMessages[Group] = NbUnreadMessages[Group];
- SetModeNotificationsCount(Group, NbUnreadMessages[Group]);
- TotalNbUnreadMessages = NbUnreadMessages["Buddies"] + NbUnreadMessages["Group"];
- }
- }
- // ---------------------------------- //
- // Animations
- // ---------------------------------- //
- // ---------------------------------- //
- // Trigger Evidence window animation
- if (PrevChatWidgetIsOpen != ChatWidgetIsOpen) {
- PrevChatWidgetIsOpen = ChatWidgetIsOpen;
- declare PositionY = C_EvidenceFramePosY;
- declare Easing = "EaseOutCirc";
- if (!ChatWidgetIsOpen) {
- PositionY += C_EvidenceFramePosHide;
- Easing = "EaseInCirc";
- }
- LibManialink_AnimStop(Frame_EvidencePlugin);
- LibManialink_Anim(Frame_EvidencePlugin, "<frame posn=\"0 "^PositionY^"\"/>", 250, Easing);
- }
- Frame_EvidencePlugin.Visible = Frame_EvidencePlugin.RelativePosition.Y != C_EvidenceFramePosY + C_EvidenceFramePosHide;
- // Set messenger window visibility
- MessengerIsOpen = (CurrentWidgetMode == "Group" || CurrentWidgetMode == "Global" || SelectedConversation != "");
- // ---------------------------------- //
- // Trigger Messenger window animation
- if (PrevMessengerIsOpen != MessengerIsOpen) {
- PrevMessengerIsOpen = MessengerIsOpen;
- declare PositionY = Frame_MessengerWindow.RelativePosition.Y;
- declare PositionX = C_MessengerFramePosX;
- declare Easing = "EaseOutCirc";
- if (!MessengerIsOpen) {
- PositionX += C_MessengerFramePosHide;
- Easing = "EaseInCirc";
- }
- LibManialink_AnimStop(Frame_MessengerWindow);
- LibManialink_Anim(Frame_MessengerWindow, "<frame posn=\""^PositionX^" "^PositionY^"\"/>", 250, Easing);
- }
- Frame_MessengerWindow.Visible = Frame_MessengerWindow.RelativePosition.Y != C_MessengerFramePosX + C_MessengerFramePosHide;
- // ---------------------------------- //
- // Update settings
- // ---------------------------------- //
- // ---------------------------------- //
- // Dynamic status
- if (UseDynamicStatus != Persistent_Evidence_UseDynamicStatus) {
- UseDynamicStatus = Persistent_Evidence_UseDynamicStatus;
- Quad_CheckUseDynamicStatus.StyleSelected = UseDynamicStatus;
- }
- // ---------------------------------- //
- // Links phrasing
- if (UseLinksPhrasing != Persistent_Evidence_UseLinksPhrasing) {
- UseLinksPhrasing = Persistent_Evidence_UseLinksPhrasing;
- Quad_CheckUseLinksPhrasing.StyleSelected = UseLinksPhrasing;
- }
- // ---------------------------------- //
- // Group Chat password
- if (GroupChatPassword != Entry_GroupChatPassword.Value) {
- GroupChatPassword = Entry_GroupChatPassword.Value;
- Persistent_Evidence_GroupChatPassword = GroupChatPassword;
- }
- // ---------------------------------- //
- // Global Chat
- if (EnableGlobalChat != Persistent_Evidence_EnableGlobalChat) {
- EnableGlobalChat = Persistent_Evidence_EnableGlobalChat;
- Quad_CheckEnableGlobalChat.StyleSelected = EnableGlobalChat;
- }
- // ---------------------------------- //
- // Notice on new message
- if (NoticeOnNewMessage != Persistent_Evidence_NoticeOnNewMessage) {
- NoticeOnNewMessage = Persistent_Evidence_NoticeOnNewMessage;
- Quad_CheckNoticeOnNewMessage.StyleSelected = NoticeOnNewMessage;
- }
- // ---------------------------------- //
- // Notice on new connection
- if (NoticeOnConnection != Persistent_Evidence_NoticeOnConnection) {
- NoticeOnConnection = Persistent_Evidence_NoticeOnConnection;
- Quad_CheckNoticeOnConnection.StyleSelected = NoticeOnConnection;
- }
- // ---------------------------------- //
- // Save Clipboard
- if (Persistent_Evidence_PasteBin != TextEdit_PasteBin.Value)
- Persistent_Evidence_PasteBin = TextEdit_PasteBin.Value;
- // ---------------------------------- //
- // Start next update check request
- if (Now > NextUpdateCheckout) {
- NextUpdateCheckout = Now + C_UpdateCheckInterval;
- // Destroy ongoing request
- if (UpdateCheckRequest != Null) {
- Http.Destroy(UpdateCheckRequest);
- UpdateCheckRequest = Null;
- }
- // Start new request
- UpdateCheckRequest = Http.CreateGet(C_UpdateCheckAddress, False);
- }
- // ---------------------------------- //
- // Display update notification
- if (UpdateCheckRequest != Null && UpdateCheckRequest.IsCompleted) {
- PluginIsOutdated = !IsNewest("{{{ScriptVersion}}}", UpdateCheckRequest.Result);
- if (PluginIsOutdated) SetModeNotificationsCount("Settings", 1);
- Http.Destroy(UpdateCheckRequest);
- UpdateCheckRequest = Null;
- }
- // Hold everything until chat is visible again
- if (!ChatWidgetIsOpen) continue;
- // ---------------------------------- //
- // Update information
- // ---------------------------------- //
- // ---------------------------------- //
- // Online buddies amount change
- if (PrevBuddiesOnline != BuddiesList_Online.count) {
- PrevBuddiesOnline = BuddiesList_Online.count;
- SortBuddiesList = True;
- }
- // ---------------------------------- //
- // Offline buddies amount change
- if (PrevBuddiesOffline != BuddiesList_Offline.count) {
- PrevBuddiesOffline = BuddiesList_Offline.count;
- SortBuddiesList = True;
- }
- // ---------------------------------- //
- // Incoming buddy requests amount change
- if (PrevBuddiesRequestFrom != BuddiesList_RequestFrom.count) {
- PrevBuddiesRequestFrom = BuddiesList_RequestFrom.count;
- SortRequestsList = True;
- SetModeNotificationsCount("Requests", PrevBuddiesRequestFrom);
- }
- // ---------------------------------- //
- // Sent buddy requests amount change
- if (PrevBuddiesRequestTo != BuddiesList_RequestTo.count) {
- PrevBuddiesRequestTo = BuddiesList_RequestTo.count;
- SortRequestsList = True;
- }
- // ---------------------------------- //
- // Sent buddy requests amount change
- if (PrevBuddiesOnServer != BuddiesList_OnServer.count) {
- PrevBuddiesOnServer = BuddiesList_OnServer.count;
- SortRequestsList = True;
- }
- // ---------------------------------- //
- // Buddies in group amount change
- if (PrevBuddiesInGroup != BuddiesList_InGroup.count) {
- PrevBuddiesInGroup = BuddiesList_InGroup.count;
- PagesCount["Group"] = (BuddiesList_InGroup.count - 1) / 10 + 1;
- if (CurrentWidgetMode == "Group") UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Buddies in global chat amount change
- if (PrevBuddiesGlobalList != BuddiesList_GlobalList.count) {
- PrevBuddiesGlobalList = BuddiesList_GlobalList.count;
- PagesCount["Global"] = (BuddiesList_GlobalList.count - 1) / 10 + 1;
- if (CurrentWidgetMode == "Global") UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Muted buddies amount change
- if (PrevBuddiesMutedUsers != BuddiesList_MutedUsers.count) {
- PrevBuddiesMutedUsers = BuddiesList_MutedUsers.count;
- if (CurrentWidgetMode == "Group") UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Buddy changed his name
- foreach (Login => Name in BuddiesName) {
- if (!PrevBuddiesName.existskey(Login) || PrevBuddiesName[Login] != Name) {
- PrevBuddiesName[Login] = Name;
- UpdateBuddiesList = True;
- // Update messenger window
- if (Login == SelectedConversation || CurrentWidgetMode == "Group" || CurrentWidgetMode == "Global") {
- UpdateMessengerInfo = True;
- UpdateMessagesSlots = 2;
- }
- }
- }
- // ---------------------------------- //
- // Buddy changed his presence
- foreach (Login => PresenceId in BuddiesPresenceId) {
- if (!PrevBuddiesPresenceId.existskey(Login) || PrevBuddiesPresenceId[Login] != PresenceId) {
- PrevBuddiesPresenceId[Login] = PresenceId;
- SortBuddiesList = True;
- UpdateBuddiesList = True;
- // Update messenger window
- if (Login == SelectedConversation || CurrentWidgetMode == "Group" || CurrentWidgetMode == "Global") {
- UpdateMessengerInfo = True;
- UpdateMessagesSlots = 2;
- }
- }
- }
- // ---------------------------------- //
- // Buddy changed his status
- foreach (Login => Status in BuddiesStatus) {
- if (!PrevBuddiesStatus.existskey(Login) || PrevBuddiesStatus[Login] != Status) {
- PrevBuddiesStatus[Login] = Status;
- UpdateBuddiesList = True;
- // Update messenger window
- if (Login == SelectedConversation) UpdateMessengerInfo = True;
- }
- }
- // ---------------------------------- //
- // Buddy changed his server
- foreach (Login => ServerLogin in BuddiesServerLogin) {
- if (!PrevBuddiesServerLogin.existskey(Login) || PrevBuddiesServerLogin[Login] != ServerLogin) {
- PrevBuddiesServerLogin[Login] = ServerLogin;
- UpdateBuddiesList = True;
- // Update messenger window
- if (Login == SelectedConversation) UpdateMessengerInfo = True;
- }
- }
- // ---------------------------------- //
- // Global Chat users update
- // ---------------------------------- //
- // ---------------------------------- //
- // User changed his name
- foreach (Login => Name in GlobalChat_BuddiesName) {
- if (!PrevGlobalBuddiesName.existskey(Login) || PrevGlobalBuddiesName[Login] != Name) {
- PrevGlobalBuddiesName[Login] = Name;
- UpdateBuddiesList = True;
- // Update messenger window
- if (CurrentWidgetMode == "Global") {
- UpdateMessengerInfo = True;
- UpdateMessagesSlots = 2;
- }
- }
- }
- // ---------------------------------- //
- // User changed his presence
- foreach (Login => PresenceId in GlobalChat_BuddiesPresenceId) {
- if (!PrevGlobalBuddiesPresenceId.existskey(Login) || PrevGlobalBuddiesPresenceId[Login] != PresenceId) {
- PrevGlobalBuddiesPresenceId[Login] = PresenceId;
- UpdateBuddiesList = True;
- // Update messenger window
- if (CurrentWidgetMode == "Global") {
- UpdateMessengerInfo = True;
- UpdateMessagesSlots = 2;
- }
- }
- }
- // ---------------------------------- //
- // Evidence widget
- // ---------------------------------- //
- // ---------------------------------- //
- // Widget mode change
- if (PrevWidgetMode != CurrentWidgetMode) {
- UpdateModeButtons = True;
- UpdateBuddiesList = True;
- UpdateMessengerInfo = True;
- // ---------------------------------- //
- // Set local user card visibility
- if (Frame_SearchModeCard.Visible && CurrentWidgetMode != "Buddies") Frame_SearchModeCard.Hide();
- declare ModesUsingLocalSlot = ["Buddies", "Group", "Global"];
- Frame_LocalUserSlot.Visible = ModesUsingLocalSlot.exists(CurrentWidgetMode) && !Frame_SearchModeCard.Visible;
- Frame_BuddyInviteCard.Visible = CurrentWidgetMode == "Requests";
- Frame_SettingsMenu.Visible = CurrentWidgetMode == "Settings";
- TextEdit_PasteBin.Visible = CurrentWidgetMode == "Settings";
- Label_ButtonUpdate.Visible = (CurrentWidgetMode == "Settings" && PluginIsOutdated);
- // ---------------------------------- //
- // Reset search mode
- Quad_LocalUserSearch.Visible = CurrentWidgetMode == "Buddies" && !Frame_SearchModeCard.Visible;
- Entry_SearchModeInput.Value = "";
- // ---------------------------------- //
- // Update messages slots
- declare MessageUpdateModes = ["Group", "Global"];
- if (MessageUpdateModes.exists(CurrentWidgetMode) || (MessageUpdateModes.exists(PrevWidgetMode) && SelectedConversation != "")) {
- PrevMessengerIsOpen = False;
- UpdateMessagesSlots = 2;
- }
- PrevWidgetMode = CurrentWidgetMode;
- }
- // ---------------------------------- //
- // Set mode buttons color
- if (UpdateModeButtons) {
- UpdateModeButtons = False;
- foreach (Mode => Frame in Frame_ModeButtons) {
- declare Quad_ModeButtonIcon <=> (Frame.GetFirstChild("Quad_ModeButtonIcon") as CMlQuad);
- Quad_ModeButtonIcon.Opacity = C_ModeButtonsOpacity[CurrentWidgetMode == Mode][(HighlightModeButton == Mode)];
- }
- }
- // ---------------------------------- //
- // Custom status updates
- if (PrevEntryStatusValue != Entry_MessengerStatusInput.Value) {
- PrevEntryStatusValue = Entry_MessengerStatusInput.Value;
- Persistent_Evidence_UserCustomStatus = PrevEntryStatusValue;
- ManialinkCustomStatus = PrevEntryStatusValue;
- }
- // ---------------------------------- //
- // Force sort buddies list
- if (SortBuddiesList) {
- SortBuddiesList = False;
- BuddiesList_SortedList.clear();
- if (CurrentWidgetMode == "Buddies") UpdateBuddiesList = True;
- // Online buddies listed on top
- foreach (Login in BuddiesList_ListOnTop)
- if (BuddiesList_Online.exists(Login)) BuddiesList_SortedList.add(Login);
- // Other online buddies
- foreach (Login in BuddiesList_Online)
- if (!BuddiesList_SortedList.exists(Login)) BuddiesList_SortedList.add(Login);
- // Offline buddies listed top
- foreach (Login in BuddiesList_ListOnTop)
- if (BuddiesList_Offline.exists(Login)) BuddiesList_SortedList.add(Login);
- // Other offline buddies
- foreach (Login in BuddiesList_Offline)
- if (!BuddiesList_SortedList.exists(Login)) BuddiesList_SortedList.add(Login);
- // Update pages amount
- PagesCount["Buddies"] = (BuddiesList_SortedList.count - 1) / 10 + 1;
- if (CurrentPage["Buddies"] > PagesCount["Buddies"]) CurrentPage["Buddies"] = PagesCount["Buddies"];
- }
- // ---------------------------------- //
- // Force sort requests list
- if (SortRequestsList) {
- SortRequestsList = False;
- BuddiesList_RequestList.clear();
- if (CurrentWidgetMode == "Requests") UpdateBuddiesList = True;
- foreach (Login in BuddiesList_RequestFrom) BuddiesList_RequestList.add(Login);
- foreach (Login in BuddiesList_RequestTo) BuddiesList_RequestList.add(Login);
- foreach (Login in BuddiesList_OnServer) {
- if (
- !BuddiesList_Online.exists(Login) && !BuddiesList_Offline.exists(Login) &&
- !BuddiesList_RequestFrom.exists(Login) && !BuddiesList_RequestTo.exists(Login)
- )
- BuddiesList_RequestList.add(Login);
- }
- // Update pages amount
- PagesCount["Requests"] = (BuddiesList_RequestList.count - 1) / 10 + 1;
- if (CurrentPage["Requests"] > PagesCount["Requests"]) CurrentPage["Requests"] = PagesCount["Requests"];
- }
- // ---------------------------------- //
- // Update searched buddies list
- if (PrevEntrySearchValue != Entry_SearchModeInput.Value) {
- BuddiesList_SearchList.clear();
- // ---------------------------------- //
- // Find matching players
- if (Entry_SearchModeInput.Value != "") {
- declare Text[] CompleteList;
- foreach (Login in BuddiesList_Online) CompleteList.add(Login);
- foreach (Login in BuddiesList_Offline) CompleteList.add(Login);
- foreach (Login in BuddiesList_RequestFrom) CompleteList.add(Login);
- foreach (Login in BuddiesList_RequestTo) CompleteList.add(Login);
- foreach (Login in BuddiesList_OnServer) CompleteList.add(Login);
- foreach (Login in CompleteList) {
- if (
- TL::Find(Entry_SearchModeInput.Value, Login, False, False) ||
- (BuddiesName.existskey(Login) && TL::Find(Entry_SearchModeInput.Value, BuddiesName[Login], False, False))
- )
- BuddiesList_SearchList.add(Login);
- }
- }
- // ---------------------------------- //
- // Revert search mode if entry id empty
- if (PrevEntrySearchValue != "" && Entry_SearchModeInput.Value == "") {
- Frame_SearchModeCard.Visible = False;
- PrevWidgetMode = "";
- }
- PrevEntrySearchValue = Entry_SearchModeInput.Value;
- CurrentPage["Search"] = 1;
- PagesCount["Search"] = (BuddiesList_SearchList.count - 1) / 10 + 1;
- UpdateBuddiesList = True;
- }
- // ---------------------------------- //
- // Update buddies list slots
- if (UpdateBuddiesList) {
- UpdateBuddiesList = False;
- UpdateSlotsBgSlots = True;
- // ---------------------------------- //
- // Configure page switch
- declare PagerMode = CurrentWidgetMode;
- if (Frame_SearchModeCard.Visible) PagerMode = "Search";
- declare ListCurrentPage = CurrentPage[PagerMode];
- declare ListPagesCount = PagesCount[PagerMode];
- Frame_PageSwitch.Visible = (ListPagesCount > 1);
- if (Frame_PageSwitch.Visible) {
- Label_PageSwitchCounter.SetText(ListCurrentPage^" / "^ListPagesCount);
- Quad_PrevBuddiesPage.Visible = (ListCurrentPage > 1);
- Quad_NextBuddiesPage.Visible = (ListCurrentPage < ListPagesCount);
- }
- // ---------------------------------- //
- // Setup slots
- declare ListPageIndexOffset = (ListCurrentPage - 1) * 10;
- foreach (I => Frame in Frame_BuddiesSlots) {
- declare BuddyId = I + ListPageIndexOffset;
- declare Text BuddyLogin;
- // ---------------------------------- //
- // Get current buddy
- switch (CurrentWidgetMode) {
- case "Buddies" : {
- if (Frame_SearchModeCard.Visible) {
- if (BuddiesList_SearchList.existskey(BuddyId)) BuddyLogin = BuddiesList_SearchList[BuddyId];
- }
- else if (BuddiesList_SortedList.existskey(BuddyId)) BuddyLogin = BuddiesList_SortedList[BuddyId];
- }
- case "Group" : if (BuddiesList_InGroup.existskey(BuddyId)) BuddyLogin = BuddiesList_InGroup[BuddyId];
- case "Requests" : if (BuddiesList_RequestList.existskey(BuddyId)) BuddyLogin = BuddiesList_RequestList[BuddyId];
- case "Global" : if (BuddiesList_GlobalList.existskey(BuddyId)) BuddyLogin = BuddiesList_GlobalList[BuddyId];
- }
- Frame.Visible = (BuddyLogin != "");
- if (!Frame.Visible) continue;
- // ---------------------------------- //
- // Load buddy slot elements
- declare Quad_BuddySlotBgCard <=> (Frame.GetFirstChild("Quad_BuddySlotBgCard") as CMlQuad);
- declare Label_BuddySlotName <=> (Frame.GetFirstChild("Label_BuddySlotName") as CMlLabel);
- declare Quad_BuddySlotPresence <=> (Frame.GetFirstChild("Quad_BuddySlotPresence") as CMlQuad);
- declare Quad_BuddySlotGlow <=> (Frame.GetFirstChild("Quad_BuddySlotGlow") as CMlQuad);
- declare Label_BuddySlotStatus <=> (Frame.GetFirstChild("Label_BuddySlotStatus") as CMlLabel);
- declare Label_EvidenceUser <=> (Frame.GetFirstChild("Label_EvidenceUser") as CMlLabel);
- declare Quad_BuddySlotBtnJoin <=> (Frame.GetFirstChild("Quad_BuddySlotBtnJoin") as CMlQuad);
- declare Quad_BuddySlotBtnAdd <=> (Frame.GetFirstChild("Quad_BuddySlotBtnAdd") as CMlQuad);
- declare Quad_BuddySlotBtnDeny <=> (Frame.GetFirstChild("Quad_BuddySlotBtnDeny") as CMlQuad);
- declare Quad_BuddySlotBtnPlus <=> (Frame.GetFirstChild("Quad_BuddySlotBtnPlus") as CMlQuad);
- declare Quad_BuddySlotBtnKick <=> (Frame.GetFirstChild("Quad_BuddySlotBtnKick") as CMlQuad);
- declare Quad_BuddySlotBtnMute <=> (Frame.GetFirstChild("Quad_BuddySlotBtnMute") as CMlQuad);
- // ---------------------------------- //
- // Set buddy name
- declare BuddyName = BuddyLogin;
- if (BuddiesName.existskey(BuddyLogin)) BuddyName = BuddiesName[BuddyLogin];
- else if (GlobalChat_BuddiesName.existskey(BuddyLogin)) BuddyName = GlobalChat_BuddiesName[BuddyLogin];
- Label_BuddySlotName.SetText(BuddyName);
- // ---------------------------------- //
- // Set buddy presence
- declare BuddyPresenceId = 0;
- if (BuddiesPresenceId.existskey(BuddyLogin)) BuddyPresenceId = BuddiesPresenceId[BuddyLogin];
- else if (GlobalChat_BuddiesPresenceId.existskey(BuddyLogin)) BuddyPresenceId = GlobalChat_BuddiesPresenceId[BuddyLogin];
- Quad_BuddySlotPresence.BgColor = C_UserPresenceColors[BuddyPresenceId];
- Quad_BuddySlotGlow.Colorize = Quad_BuddySlotPresence.BgColor;
- Quad_BuddySlotGlow.Visible = (BuddyPresenceId > 0);
- // ---------------------------------- //
- // Set buddy status text
- declare BuddyStatus = C_UserPresenceStatus[BuddyPresenceId];
- // Put server name or login in buddy status
- if (BuddiesServerLogin.existskey(BuddyLogin) && BuddiesServerLogin[BuddyLogin] != "") {
- declare ServerLogin = BuddiesServerLogin[BuddyLogin];
- if (!ServersName.existskey(ServerLogin)) BuddyStatus = ServerLogin;
- else BuddyStatus = ServersName[ServerLogin];
- }
- // Put buddys own status
- else if (BuddiesStatus.existskey(BuddyLogin) && BuddiesStatus[BuddyLogin] != "")
- BuddyStatus = BuddiesStatus[BuddyLogin];
- // Put Global Chat buddy status
- else if (GlobalChat_BuddiesStatus.existskey(BuddyLogin) && GlobalChat_BuddiesStatus[BuddyLogin] != "")
- BuddyStatus = GlobalChat_BuddiesStatus[BuddyLogin];
- Label_BuddySlotStatus.SetText(BuddyStatus);
- // ---------------------------------- //
- // Setup background
- Quad_BuddySlotBgCard.DataAttributeSet("login", BuddyLogin);
- // ---------------------------------- //
- // Setup join button
- Quad_BuddySlotBtnJoin.Visible = (
- CurrentWidgetMode == "Buddies" &&
- BuddiesJoinLink.existskey(BuddyLogin) && BuddiesJoinLink[BuddyLogin] != ""
- );
- if (Quad_BuddySlotBtnJoin.Visible)
- Quad_BuddySlotBtnJoin.DataAttributeSet("manialink", BuddiesJoinLink[BuddyLogin]);
- // ---------------------------------- //
- // Display Evidence information
- Label_EvidenceUser.Visible = BuddiesList_Evidence.exists(BuddyLogin);
- // ---------------------------------- //
- // Accept / refuse buttons
- Quad_BuddySlotBtnAdd.Visible = (CurrentWidgetMode == "Requests" && BuddiesList_RequestFrom.exists(BuddyLogin));
- Quad_BuddySlotBtnDeny.Visible = (CurrentWidgetMode == "Requests" && (BuddiesList_RequestTo.exists(BuddyLogin) || BuddiesList_RequestFrom.exists(BuddyLogin)));
- Quad_BuddySlotBtnPlus.Visible = (CurrentWidgetMode == "Requests" && !Quad_BuddySlotBtnDeny.Visible && BuddiesList_OnServer.exists(BuddyLogin));
- if (CurrentWidgetMode == "Requests") {
- Quad_BuddySlotBtnDeny.DataAttributeSet("login", BuddyLogin);
- Quad_BuddySlotBtnAdd.DataAttributeSet("login", BuddyLogin);
- Quad_BuddySlotBtnPlus.DataAttributeSet("login", BuddyLogin);
- // ---------------------------------- //
- // Replacement status
- declare Text ReplacementStatus;
- if (Quad_BuddySlotBtnAdd.Visible)
- ReplacementStatus = "Incoming invitation";
- else if (Quad_BuddySlotBtnDeny.Visible)
- ReplacementStatus = "Sent invitation";
- else if (BuddiesList_OnServer.exists(BuddyLogin))
- ReplacementStatus = "Playing on this server";
- if (ReplacementStatus != "") Label_BuddySlotStatus.SetText(ReplacementStatus);
- }
- // ---------------------------------- //
- // Kick from the group button
- Quad_BuddySlotBtnKick.Visible = (CurrentWidgetMode == "Group");
- if (Quad_BuddySlotBtnKick.Visible)
- Quad_BuddySlotBtnKick.DataAttributeSet("command", "/kick "^BuddyLogin);
- // ---------------------------------- //
- // Mute user button
- Quad_BuddySlotBtnMute.Visible = (CurrentWidgetMode == "Group");
- if (Quad_BuddySlotBtnMute.Visible) {
- declare BuddyIsMuted = BuddiesList_MutedUsers.exists(BuddyLogin);
- Quad_BuddySlotBtnMute.ImageUrl = C_SlotMuteButtonImages[BuddyIsMuted][False];
- Quad_BuddySlotBtnMute.ImageUrlFocus = C_SlotMuteButtonImages[BuddyIsMuted][True];
- if (!BuddyIsMuted) Quad_BuddySlotBtnMute.DataAttributeSet("command", "/mute "^BuddyLogin);
- else Quad_BuddySlotBtnMute.DataAttributeSet("command", "/unmute "^BuddyLogin);
- }
- }
- }
- // ---------------------------------- //
- // Update buddies slots backgrounds colors
- if (UpdateSlotsBgSlots) {
- UpdateSlotsBgSlots = False;
- Quad_LocalUserBgCard.BgColor = C_BuddySlotBgColors[False][Quad_LocalUserBgCard.Id == HighlightBuddySlot];
- declare Modes = ["Buddies", "Requests"];
- foreach (Frame in Frame_BuddiesSlots) {
- if (!Frame.Visible) continue;
- declare Quad_BuddySlotBgCard <=> (Frame.GetFirstChild("Quad_BuddySlotBgCard") as CMlQuad);
- declare BuddyLogin = Quad_BuddySlotBgCard.DataAttributeGet("login");
- declare SlotIsSelected = (Modes.exists(CurrentWidgetMode) && SelectedConversation == BuddyLogin);
- Quad_BuddySlotBgCard.BgColor = C_BuddySlotBgColors[SlotIsSelected][(Quad_BuddySlotBgCard.Id == HighlightBuddySlot)];
- }
- }
- // ---------------------------------- //
- // Blink buddies cards on new messages
- foreach (Frame in Frame_BuddiesSlots) {
- if (!Frame.Visible) continue;
- declare Quad_BuddySlotBgCard <=> (Frame.GetFirstChild("Quad_BuddySlotBgCard") as CMlQuad);
- declare Quad_BuddySlotBlink <=> (Frame.GetFirstChild("Quad_BuddySlotBlink") as CMlQuad);
- declare Label_BuddySlotNbNotice <=> (Frame.GetFirstChild("Label_BuddySlotNbNotice") as CMlLabel);
- declare BuddyLogin = Quad_BuddySlotBgCard.DataAttributeGet("login");
- // Get amount of unread messages from slot buddy
- declare Integer BuddyNbUnreadMessages;
- if (Persistent_Evidence_NbUnreadMessages.existskey(BuddyLogin))
- BuddyNbUnreadMessages = Persistent_Evidence_NbUnreadMessages[BuddyLogin];
- // Blink card background
- if (BuddyNbUnreadMessages <= 0) Quad_BuddySlotBlink.Opacity = 0.;
- else Quad_BuddySlotBlink.Opacity = Pulse(Now, 1.) / 2;
- // Set unread messages counter
- Label_BuddySlotNbNotice.Visible = (BuddyNbUnreadMessages > 0);
- if (Label_BuddySlotNbNotice.Visible)
- Label_BuddySlotNbNotice.Value = TL::ToText(BuddyNbUnreadMessages);
- }
- if (Frame_LocalUserSlot.Visible) {
- // ---------------------------------- //
- // Update local user name
- if (Label_LocalUserBgName.Value != LocalUser.Name) {
- Label_LocalUserBgName.SetText(LocalUser.Name);
- if (CurrentWidgetMode == "Group") UpdateMessengerInfo = True;
- }
- // ---------------------------------- //
- // Update local presence light
- if (PrevPluginPresenceId != CurrentPluginPresenceId) {
- PrevPluginPresenceId = CurrentPluginPresenceId;
- if (CurrentWidgetMode == "Group") UpdateMessengerInfo = True;
- if (CurrentPluginPresenceId >= 0) {
- Quad_LocalUserPresence.BgColor = C_UserPresenceColors[CurrentPluginPresenceId];
- Quad_LocalUserGlow.Visible = (CurrentPluginPresenceId > 0);
- Quad_LocalUserGlow.Colorize = Quad_LocalUserPresence.BgColor;
- }
- }
- // ---------------------------------- //
- // Update local user status
- if (Label_LocalUserStatus.Value != CurrentPluginStatusText) {
- Label_LocalUserStatus.SetText(CurrentPluginStatusText);
- if (CurrentWidgetMode == "Group") UpdateMessengerInfo = True;
- }
- }
- // ---------------------------------- //
- // Update mails amount
- if (PrevLegacyMailsAmount != LegacyMailsAmount) {
- PrevLegacyMailsAmount = LegacyMailsAmount;
- SetModeNotificationsCount("Mailbox", LegacyMailsAmount);
- }
- // ---------------------------------- //
- // Change add buddy button visibility
- if (Frame_BuddyInviteCard.Visible) {
- Quad_InvitePlayerButton.Visible = (Entry_InvitePlayerInput.Value != "");
- }
- // Dont update messenger if it's hidden
- if (!MessengerIsOpen) continue;
- // ---------------------------------- //
- // Messenger window
- // ---------------------------------- //
- // ---------------------------------- //
- // Update messenger on conversation change
- if (PrevSelectedConversation != SelectedConversation) {
- PrevSelectedConversation = SelectedConversation;
- UpdateMessagesSlots = 2;
- UpdateMessengerInfo = True;
- // ---------------------------------- //
- // Trigger window animation
- if (SelectedConversation != "") {
- PrevMessengerIsOpen = False;
- Frame_MessengerWindow.RelativePosition.X = C_MessengerFramePosX + C_MessengerFramePosHide;
- }
- }
- // ---------------------------------- //
- // Update messages Slots
- if (UpdateMessagesSlots > 0) {
- UpdateMessagesSlots -= 1;
- declare CurrentOffsetY = 0.;
- Quad_SeenMessage.Hide();
- // ---------------------------------- //
- // Select active conversation
- declare Text BuddyLogin;
- switch (CurrentWidgetMode) {
- case "Group" : BuddyLogin = "*group*";
- case "Global" : BuddyLogin = "*global*";
- default : BuddyLogin = SelectedConversation;
- }
- // ---------------------------------- //
- // Reset unread messages amount
- if (
- GameIsInFocus &&
- Persistent_Evidence_NbUnreadMessages.existskey(BuddyLogin) &&
- Persistent_Evidence_NbUnreadMessages[BuddyLogin] > 0
- ) {
- Persistent_Evidence_NbUnreadMessages[BuddyLogin] = 0;
- SendCustomEvent("SeenMessage", [BuddyLogin]);
- }
- // ---------------------------------- //
- // Initialize conversation history array if empty
- if (
- !Persistent_Evidence_ChatHistoryBody.existskey(BuddyLogin) ||
- !Persistent_Evidence_ChatHistorySender.existskey(BuddyLogin) ||
- !Persistent_Evidence_ChatHistoryDate.existskey(BuddyLogin)
- ) {
- Persistent_Evidence_ChatHistoryBody[BuddyLogin] = Text[];
- Persistent_Evidence_ChatHistorySender[BuddyLogin] = Text[];
- Persistent_Evidence_ChatHistoryDate[BuddyLogin] = Text[];
- }
- // ---------------------------------- //
- // Setup scrolling buttons
- declare MessageOffset = 0;
- if (MessagesOffset.existskey(BuddyLogin)) MessageOffset = MessagesOffset[BuddyLogin];
- Quad_MessagesScrollUp.Visible = (MessageOffset < Persistent_Evidence_ChatHistoryBody[BuddyLogin].count - 1);
- Quad_MessagesScrollDown.Visible = (MessageOffset > 0);
- // ---------------------------------- //
- // Format messages frames
- foreach (I => Frame in Frame_MessagesSlots) {
- declare Text SenderLogin;
- declare Text MessageBody;
- declare Text MessageTime;
- // ---------------------------------- //
- // Load message from history
- if (Persistent_Evidence_ChatHistoryBody.existskey(BuddyLogin)) {
- declare Index = Persistent_Evidence_ChatHistoryBody[BuddyLogin].count - 1 - I - MessageOffset;
- if (Persistent_Evidence_ChatHistoryBody[BuddyLogin].existskey(Index))
- MessageBody = Persistent_Evidence_ChatHistoryBody[BuddyLogin][Index];
- if (Persistent_Evidence_ChatHistorySender[BuddyLogin].existskey(Index))
- SenderLogin = Persistent_Evidence_ChatHistorySender[BuddyLogin][Index];
- if (Persistent_Evidence_ChatHistoryDate[BuddyLogin].existskey(Index))
- MessageTime = Persistent_Evidence_ChatHistoryDate[BuddyLogin][Index];
- }
- // ---------------------------------- //
- // Show the "seen" check
- Quad_SeenMessage.Visible = SenderLogin == LocalUser.Login && Persistent_Evidence_UsersSeenMessages.exists(BuddyLogin);
- Frame.Visible = MessageBody != "";
- if (!Frame.Visible) continue;
- // ---------------------------------- //
- // Load message slot elements
- declare Quad_MessageSlotBgCard <=> (Frame.GetFirstChild("Quad_MessageSlotBgCard") as CMlQuad);
- declare Label_MessageSlotName <=> (Frame.GetFirstChild("Label_MessageSlotName") as CMlLabel);
- declare Label_MessageSlotBody <=> (Frame.GetFirstChild("Label_MessageSlotBody") as CMlLabel);
- declare Label_MessageSlotTime <=> (Frame.GetFirstChild("Label_MessageSlotTime") as CMlLabel);
- declare Quad_MessageSlotBtnCopy <=> (Frame.GetFirstChild("Quad_MessageSlotBtnCopy") as CMlQuad);
- declare Quad_MessageSlotImage <=> (Frame.GetFirstChild("Quad_MessageSlotImage") as CMlQuad);
- // Set sender login
- declare SenderName = SenderLogin;
- if (SenderLogin == "") SenderName = "$t$888Evidence";
- else if (SenderLogin == LocalUser.Login) SenderName = LocalUser.Name;
- else if (BuddiesName.existskey(SenderLogin)) SenderName = BuddiesName[SenderLogin];
- else if (GlobalChat_BuddiesName.existskey(SenderLogin)) SenderName = GlobalChat_BuddiesName[SenderLogin];
- Label_MessageSlotName.SetText(SenderName);
- // ---------------------------------- //
- // Display message as image
- Quad_MessageSlotImage.Visible = TL::SubText(MessageBody, 0, 6) == "image:";
- if (Quad_MessageSlotImage.Visible) {
- Quad_MessageSlotImage.ImageUrl = TL::Replace(MessageBody, "image:", "");
- Quad_MessageSlotImage.Size.X = Quad_MessageSlotImage.Size.Y;
- if (TL::Find(".webm", MessageBody, False, False)) Quad_MessageSlotImage.Size.X *= 16/9.;
- }
- // ---------------------------------- //
- // Message body
- if (!Quad_MessageSlotImage.Visible) Label_MessageSlotBody.SetText(MessageBody);
- else Label_MessageSlotBody.SetText("");
- // ---------------------------------- //
- // Message time
- Label_MessageSlotTime.SetText(MessageTime);
- // ---------------------------------- //
- // Sender presence
- if (SenderLogin == LocalUser.Login || SenderLogin == "") Quad_MessageSlotBgCard.BgColor = <0., 0., 0.>;
- else if (BuddiesPresenceId.existskey(SenderLogin))
- Quad_MessageSlotBgCard.BgColor = C_UserPresenceColors[BuddiesPresenceId[SenderLogin]];
- else if (GlobalChat_BuddiesPresenceId.existskey(SenderLogin))
- Quad_MessageSlotBgCard.BgColor = C_UserPresenceColors[GlobalChat_BuddiesPresenceId[SenderLogin]];
- else
- Quad_MessageSlotBgCard.BgColor = C_UserPresenceColors[0];
- // ---------------------------------- //
- // Copy button
- declare ClipboardContent = Label_MessageSlotBody.Value;
- if (Quad_MessageSlotImage.Visible) ClipboardContent = Quad_MessageSlotImage.ImageUrl;
- Quad_MessageSlotBtnCopy.DataAttributeSet("clipboard", ClipboardContent);
- // ---------------------------------- //
- // Frame position
- declare PositionX = 0.;
- if (SenderLogin == LocalUser.Login) PositionX = 8.;
- Frame.RelativePosition.X = PositionX;
- Quad_MessageSlotBgCard.Size.Y = 3 * Label_MessageSlotBody.ValueLineCount + 4.5;
- if (Quad_MessageSlotImage.Visible) Quad_MessageSlotBgCard.Size.Y += Quad_MessageSlotImage.Size.Y - 2;
- CurrentOffsetY += Quad_MessageSlotBgCard.Size.Y + .5;
- Frame.RelativePosition.Y = CurrentOffsetY;
- }
- }
- // ---------------------------------- //
- // Update info on Global Chat connection change
- if (PrevGlobalChatConnectionStatus != GlobalChat_ConnectionStatus) {
- PrevGlobalChatConnectionStatus = GlobalChat_ConnectionStatus;
- UpdateMessengerInfo = True;
- }
- // ---------------------------------- //
- // Update name and status of curreent conversation buddy
- if (UpdateMessengerInfo) {
- UpdateMessengerInfo = False;
- // ---------------------------------- //
- // Set conversation name
- declare Text ConversationName;
- declare Text ConversationLogin;
- switch (CurrentWidgetMode) {
- case "Group" : {
- ConversationName = LocalUser.Name;
- ConversationLogin = LocalUser.Login;
- }
- case "Global" : ConversationName = "Evidence Global Chat";
- default : {
- ConversationLogin = SelectedConversation;
- if (BuddiesName.existskey(ConversationLogin)) ConversationName = BuddiesName[ConversationLogin];
- else ConversationName = ConversationLogin;
- }
- }
- Label_MessengerBuddyName.SetText(ConversationName);
- // ---------------------------------- //
- // Set conversation presence
- declare Integer PresenceId;
- switch (CurrentWidgetMode) {
- case "Group" : PresenceId = CurrentPluginPresenceId;
- case "Global" : PresenceId = GlobalChat_ConnectionStatus;
- default : {
- if (BuddiesPresenceId.existskey(ConversationLogin)) PresenceId = BuddiesPresenceId[ConversationLogin];
- }
- }
- if (PresenceId >= 0) Quad_MessengerBuddyPresence.Colorize = C_UserPresenceColors[PresenceId];
- // ---------------------------------- //
- // Set conversation status
- Label_MessengerBuddyStatus.Visible = (CurrentWidgetMode != "Group");
- if (Label_MessengerBuddyStatus.Visible) {
- declare StatusText = C_UserPresenceStatus[0];
- switch (CurrentWidgetMode) {
- case "Global" : StatusText = C_GlobalChatConnectionStatus[GlobalChat_ConnectionStatus];
- default : {
- if (BuddiesStatus.existskey(ConversationLogin)) StatusText = BuddiesStatus[ConversationLogin];
- }
- }
- Label_MessengerBuddyStatus.SetText(StatusText);
- }
- // ---------------------------------- //
- // Show status edition field
- Entry_MessengerStatusInput.Visible = (CurrentWidgetMode == "Group");
- if (Entry_MessengerStatusInput.Visible) {
- Entry_MessengerStatusInput.Value = ManialinkCustomStatus;
- }
- // ---------------------------------- //
- // Configure action buttons
- Frame_MessengerBuddyActions.Visible = (CurrentWidgetMode != "Group" && CurrentWidgetMode != "Global");
- if (Frame_MessengerBuddyActions.Visible) {
- // ---------------------------------- //
- // Set buddy login
- Label_MessengerBuddyLogin.SetText(ConversationLogin);
- // ---------------------------------- //
- // Set buddy server name
- declare ServerName = _("Not playing on a server");
- if (BuddiesServerLogin.existskey(ConversationLogin) && BuddiesServerLogin[ConversationLogin] != "") {
- declare ServerLogin = BuddiesServerLogin[ConversationLogin];
- if (!ServersName.existskey(ServerLogin)) ServerName = ServerLogin;
- else ServerName = ServersName[ServerLogin];
- }
- Label_MessengerBuddyServer.SetText(ServerName);
- // ---------------------------------- //
- // Setup join button
- Quad_MessengerBuddyJoin.Visible = (BuddiesJoinLink.existskey(ConversationLogin) && BuddiesJoinLink[ConversationLogin] != "");
- if (Quad_MessengerBuddyJoin.Visible)
- Quad_MessengerBuddyJoin.DataAttributeSet("manialink", BuddiesJoinLink[ConversationLogin]);
- // ---------------------------------- //
- // Setup mail button
- Quad_MessengerBuddyMail.DataAttributeSet("login", ConversationLogin);
- // ---------------------------------- //
- // Setup remove button
- Quad_MessengerBuddyRemove.DataAttributeSet("login", ConversationLogin);
- }
- }
- ***
- // ---------------------------------- //
- // Functions
- // ---------------------------------- //
- // ---------------------------------- //
- /** Compute width of the label text
- *
- * @param _Label Label to check text length
- * @return Width of the label text
- */
- Real ComputeWidth(CMlLabel _Label) {
- if (_Label == Null) return 0.;
- return _Label.ComputeWidth(_Label.Value) * _Label.RelativeScale;
- }
- // ---------------------------------- //
- /** Change number of notifications in mode button
- *
- * @param _Mode Mode to set noticifications amount
- * @param _NotificationsCount Amount of the notifications to set
- */
- Void SetModeNotificationsCount(Text _Mode, Integer _NotificationsCount) {
- if (!C_ChatWidgetModes.exists(_Mode)) return;
- declare Frame <=> (Page.GetFirstChild("Frame_ModeButton"^_Mode) as CMlFrame);
- declare Frame_ModeButtonNotice <=> (Frame.GetFirstChild("Frame_ModeButtonNotice") as CMlFrame);
- declare Label_ModeButtonNotice <=> (Frame.GetFirstChild("Label_ModeButtonNotice") as CMlLabel);
- Frame_ModeButtonNotice.Visible = (_NotificationsCount > 0);
- if (Frame_ModeButtonNotice.Visible)
- Label_ModeButtonNotice.SetText(TL::ToText(_NotificationsCount));
- }
- // ---------------------------------- //
- /** Return pulse value for animations
- *
- * @param _Time Time of the pulse animations
- * @param _Frequency Frequency of the pulse in Hz
- *
- * @return Pulse animation value
- */
- Real Pulse(Integer _Time, Real _Frequency) {
- return (ML::Sin(ML::PI() * 2 * (_Time / 1000.) * _Frequency) + 1) / 2;
- }
- // ---------------------------------- //
- /** Detect and automatically format sent and received URLs
- *
- * @param _InputText Text to find and format URLs
- *
- * @return Formatted text
- */
- Text AutoFormatURL(Text _InputText) {
- if (_InputText == "") return "";
- declare TextObjects = TL::Split(" ", _InputText);
- declare Text OutputText;
- foreach (I => Object in TextObjects) {
- if (I > 0) OutputText ^= " ";
- // HTTP
- if (TL::SubText(Object, 0, 7) == "http://") OutputText ^= "$<$FA3$l"^Object^"$>";
- // HTTPS
- else if (TL::SubText(Object, 0, 8) == "https://") OutputText ^= "$<$FA3$l"^Object^"$>";
- // WWW
- else if (TL::SubText(Object, 0, 4) == "www.") OutputText ^= "$<$FA3$l"^Object^"$>";
- // Manialink
- else if (TL::SubText(Object, 0, 14) == "maniaplanet://") OutputText ^= "$<$6BF$h"^Object^"$>";
- // ManiapPanet action
- else if (TL::SubText(Object, 0, 1) == "#") OutputText ^= "$<$6BF$h"^Object^"$>";
- // No address
- else OutputText ^= Object;
- }
- return OutputText;
- }
- // ---------------------------------- //
- /** Detect images links in specified message
- *
- * @param _MessageBody Text to find and images
- *
- * @return Array of images links
- */
- Text[] FindImages(Text _MessageBody) {
- if (_MessageBody == "") return Text[];
- declare Formats = ["jpg", "jpeg", "png", "tga", "dds", "webm"];
- declare TextObjects = TL::Split(" ", TL::StripFormatting(_MessageBody));
- declare Text[] Images;
- foreach (I => Object in TextObjects) {
- declare IsLink =
- TL::SubText(Object, 0, 7) == "http://" ||
- TL::SubText(Object, 0, 8) == "https://" ||
- TL::SubText(Object, 0, 4) == "www.";
- if (!IsLink) continue;
- foreach (Format in Formats) if (TL::Find("."^Format, Object, False, False)) Images.add(Object);
- }
- return Images;
- }
- // ---------------------------------- //
- /** Format message with buily-in functions
- *
- * @param _Message Message to format
- *
- * @return Formatted message
- */
- Text FormatMessage(Text _Message) {
- if (_Message == "") return "";
- declare OutputMessage = _Message;
- // ---------------------------------- //
- // Phrase links
- declare persistent Boolean Persistent_Evidence_UseLinksPhrasing for Page = True;
- if (Persistent_Evidence_UseLinksPhrasing) OutputMessage = AutoFormatURL(OutputMessage);
- return OutputMessage;
- }
- // ---------------------------------- //
- /** Check if the given text is date format
- *
- * @param _Text Text to check
- *
- * @return True, if the text is a date
- */
- Boolean TextIsDate(Text _Text) {
- if (_Text == "") return False;
- declare SplitDate = TL::Split("-", TL::Replace(_Text, "\n", ""));
- if (SplitDate.count < 3) return False;
- if (TL::Length(SplitDate[0]) != 4 || TL::Length(SplitDate[1]) != 2 || TL::Length(SplitDate[2]) != 2) return False;
- return True;
- }
- // ---------------------------------- //
- /** Check if the local date is newest
- *
- * @param _LocalDate Local script version
- * @param _OnlineDate Online script version
- *
- * @return True, if date is newest
- */
- Boolean IsNewest(Text _LocalDate, Text _OnlineDate) {
- if (!TextIsDate(_LocalDate) || !TextIsDate(_OnlineDate)) return True;
- declare LocalDate = TL::Split("-", _LocalDate);
- declare OnlineDate = TL::Split("-", _OnlineDate);
- declare IsNewestYear = TL::ToInteger(LocalDate[0]) > TL::ToInteger(OnlineDate[0]);
- if (IsNewestYear) return True;
- declare IsNewestMonth = TL::ToInteger(LocalDate[1]) > TL::ToInteger(OnlineDate[1]);
- if (IsNewestMonth) return True;
- declare IsNewestDay = TL::ToInteger(LocalDate[2]) > TL::ToInteger(OnlineDate[2]);
- if (IsNewestDay) return True;
- return False;
- }
- {{{Manialink::Animations(["EaseOutCirc", "EaseInCirc"])}}}
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- main() {
- wait(LocalUser != Null);
- +++Main+++
- while (True) {
- yield;
- LibManialink_AnimLoop();
- +++Yield+++
- }
- }
- --></script>
- </manialink>""";
- }
- Text CreateManialinkNotifications() {
- return """
- <manialink version="2" name="Evidence:Notifications" background="0">
- <framemodel id="FrameModel_Notification">
- <quad posn="0 0 .5" sizen="60 7" bgcolor="000" opacity=".875" id="Quad_Background"/>
- <quad sizen="60 7" style="Bgs1" substyle="BgDialogBlur" opacity="0"/>
- <quad posn="-2.5 2.5" sizen="130 24" scale=".5" style="Bgs1InRace" substyle="BgButtonShadow"/>
- <quad posn="1 -3.5 1" sizen="6 6" valign="center" id="Quad_NoticeIcon"/>
- <label posn="8 -2 1" sizen="33.5 3" valign="center2" scale=".9" textsize="1" textemboss="1" textcolor="AAA" id="Label_NoticeHeader"/>
- <label posn="8 -5 1" sizen="48.5 3" valign="center2" textsize="1" textemboss="1" textcolor="FFF" maxline="1" id="Label_NoticeBody"/>
- </framemodel>
- <frame id="Frame_Notifications" posn="-159.5 89.5">
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#0" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#1" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#2" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#3" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#4" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#5" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#6" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#7" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#8" hidden="1"/>
- <frameinstance modelid="FrameModel_Notification" id="Frame_Notification#9" hidden="1"/>
- </frame>
- <script><!--
- /**
- * EVIDENCE by domino54
- * Notifications manialink
- */
- #Include "MathLib" as ML
- #Include "TextLib" as TL
- #Const C_MaxNbNotifications 10
- #Const C_NoticeDisplayTime 6500
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- ***Main***
- ***
- // ---------------------------------- //
- // Load interface elements
- declare Frame_Notices <=> (Page.GetFirstChild("Frame_Notifications") as CMlFrame);
- declare CMlFrame[] Frame_Notifications;
- for (I, 0, C_MaxNbNotifications - 1)
- Frame_Notifications.add((Page.GetFirstChild("Frame_Notification#"^I) as CMlFrame));
- // ---------------------------------- //
- // Plugin shared variables
- declare Text[][] NewNotifications for Page; ///< New notifications to display
- declare Boolean ToolbarActive for Page; ///< ManiaPlanet toolbar visibility
- // ---------------------------------- //
- // Variables
- declare Text[][Integer] CurrentNotifications;
- declare Integer[] NotificationsToRemove;
- declare Boolean UpdateNotifications;
- declare PrevToolbarActive = False;
- ***
- // ---------------------------------- //
- // Yield
- // ---------------------------------- //
- ***Yield***
- ***
- // ---------------------------------- //
- // Save new notifications
- while (NewNotifications.count > 0) {
- declare NoticeData = NewNotifications[0];
- CurrentNotifications[Now] = NoticeData;
- declare Removed = NewNotifications.removekey(0);
- UpdateNotifications = True;
- // ---------------------------------- //
- // Remove oldest notification if there are too many
- if (CurrentNotifications.count > C_MaxNbNotifications) {
- declare OldestNoticeTime = 0;
- foreach (Time => NoticeData in CurrentNotifications)
- if (OldestNoticeTime == 0) OldestNoticeTime = Time;
- CurrentNotifications.removekey(OldestNoticeTime);
- }
- // ---------------------------------- //
- // Create blink animation
- declare Max = CurrentNotifications.count - 1;
- declare Quad_Background <=> (Frame_Notifications[Max].GetFirstChild("Quad_Background") as CMlQuad);
- LibManialink_AnimStop(Quad_Background);
- Quad_Background.BgColor = <.4, .7, 1.>;
- LibManialink_Anim(Quad_Background, "<quad bgcolor=\"000\"/>", 1000, "EaseOutCirc");
- }
- // ---------------------------------- //
- // Remove old notifications
- foreach (Time => NoticeData in CurrentNotifications)
- if (Now >= Time + C_NoticeDisplayTime) NotificationsToRemove.add(Time);
- if (NotificationsToRemove.count > 0) {
- UpdateNotifications = True;
- for (I, 0, NotificationsToRemove.count - 1) {
- declare Removed1 = CurrentNotifications.removekey(NotificationsToRemove[0]);
- declare Removed2 = NotificationsToRemove.removekey(0);
- }
- }
- // ---------------------------------- //
- // Update notifications models
- if (UpdateNotifications) {
- UpdateNotifications = False;
- // ---------------------------------- //
- // Hide all frames
- foreach (Frame in Frame_Notifications) {
- Frame.RelativePosition.Y = 0.;
- Frame.Hide();
- }
- declare I = 0;
- foreach (NoticeData in CurrentNotifications) {
- declare Frame = Frame_Notifications[I];
- declare Label_NoticeHeader <=> (Frame.GetFirstChild("Label_NoticeHeader") as CMlLabel);
- declare Label_NoticeBody <=> (Frame.GetFirstChild("Label_NoticeBody") as CMlLabel);
- declare Quad_NoticeIcon <=> (Frame.GetFirstChild("Quad_NoticeIcon") as CMlQuad);
- // ---------------------------------- //
- // Set notice text
- if (NoticeData.existskey(0)) Label_NoticeHeader.SetText(NoticeData[0]);
- if (NoticeData.existskey(1)) Label_NoticeBody.SetText(NoticeData[1]);
- // ---------------------------------- //
- // Set icon
- if (NoticeData.existskey(2)) {
- if (TL::Find("|", NoticeData[2], False, False)) {
- declare SplitStyle = TL::Split("|", NoticeData[2]);
- Quad_NoticeIcon.Style = SplitStyle[0];
- Quad_NoticeIcon.Substyle = SplitStyle[1];
- Quad_NoticeIcon.ImageUrl = "";
- } else {
- Quad_NoticeIcon.ImageUrl = NoticeData[2];
- }
- }
- // ---------------------------------- //
- // Move other notifications
- foreach (Frame_Notification in Frame_Notifications)
- if (Frame_Notification.Visible) Frame_Notification.RelativePosition.Y -= 7.5;
- Frame.Show();
- I += 1;
- }
- }
- // ---------------------------------- //
- // Update notifications position
- if (PrevToolbarActive != ToolbarActive) {
- PrevToolbarActive = ToolbarActive;
- Frame_Notices.RelativePosition.Y = 89.5;
- if (ToolbarActive) Frame_Notices.RelativePosition.Y -= 6;
- }
- ***
- {{{Manialink::Animations(["EaseOutCirc"])}}}
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- main() {
- +++Main+++
- while (True) {
- +++Yield+++
- LibManialink_AnimLoop();
- yield;
- }
- }
- --></script>
- </manialink>""";
- }
- // ---------------------------------- //
- // Main
- // ---------------------------------- //
- main() {
- +++Main+++
- +++GlobalChatStart+++
- while (True) {
- +++Yield+++
- // +++GlobalChatYield+++
- yield;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement