Simple Chat Server Gui to be put on a separate GameObject. Provides a global chat (in lobby) and a room chat (in room).
This script flags it's GameObject with DontDestroyOnLoad(). Make sure this is OK in your case. The Chat Server API in ChatClient basically lets you create any number of channels. You just have to name them. Example: "gc" for Global Channel or for rooms: "rc"+RoomName.GetHashCode() This simple demo sends in a global chat when in lobby and in room channel when in room. Create a more elaborate UI to let players chat in either channel while in room or send private messages. Names of users are set in Authenticate. That should be unique so users can actually get their messages. Workflow: Create ChatClient, Connect to a server with your AppID, Authenticate the user (apply a unique name) and subscribe to some channels. Subscribe a channel before you publish to that channel! Note: Don't forget to call ChatClient.Service(). Might later on be integrated into PUN but for now don't forget.
Inheritance: MonoBehaviour, IChatClientListener
Example #1
0
 public void DisplayMessage(string message)
 {
     if (Configuration.DisplayChatMessages)
     {
         ChatGui.Print(message);
     }
 }
Example #2
0
        public void DisplaySongTitle(string songTitle)
        {
            if (!Configuration.DisplayChatMessages)
            {
                return;
            }

            var message = PluginInterface.UiLanguage switch
            {
                "ja" => new SeString(new Payload[]
                {
                    new TextPayload($"「{songTitle}」を再生しました。"),     // 「Weight of the World/Prelude Version」を再生しました。
                }),
                "de" => new SeString(new Payload[]
                {
                    new TextPayload($"„{songTitle}“ wird nun wiedergegeben."),     // „Weight of the World (Prelude Version)“ wird nun wiedergegeben.
                }),
                "fr" => new SeString(new Payload[]
                {
                    new TextPayload($"Le FantasyPlayer lit désormais “{songTitle}”."),     // L'orchestrion joue désormais “Weight of the World (Prelude Version)”.
                }),
                _ => new SeString(new Payload[]
                {
                    new EmphasisItalicPayload(true),
                    new TextPayload(songTitle),     // _Weight of the World (Prelude Version)_ is now playing.
                    new EmphasisItalicPayload(false),
                    new TextPayload(" is now playing."),
                }),
            };

            ChatGui.Print(message);
        }
Example #3
0
        public Plugin(
            DalamudPluginInterface pi,
            CommandManager commands,
            ChatGui chat,
            ClientState clientState)
        {
            this.pluginInterface = pi;
            this.chat            = chat;
            this.clientState     = clientState;

            // Get or create a configuration object
            this.config = (Configuration)this.pluginInterface.GetPluginConfig()
                          ?? this.pluginInterface.Create <Configuration>();

            // Initialize the UI
            this.windowSystem = new WindowSystem(typeof(Plugin).AssemblyQualifiedName);

            var window = this.pluginInterface.Create <PluginWindow>();

            if (window is not null)
            {
                this.windowSystem.AddWindow(window);
            }

            this.pluginInterface.UiBuilder.Draw += this.windowSystem.Draw;

            // Load all of our commands
            this.commandManager = new PluginCommandManager <Plugin>(this, commands);
        }
Example #4
0
        private void FrameworkOnOnUpdateEvent(Framework framework)
        {
            if (this.Disable)
            {
                this.characterDrawResolver.ShowAll();

                this.Disable = false;

                if (this.refresh)
                {
                    Task.Run(
                        async() =>
                    {
                        await Task.Delay(250);
                        this.Configuration.Enabled = true;
                        ChatGui.Print(this.PluginLocalization.RefreshComplete);
                    });
                }

                this.refresh = false;
            }
            else if (this.refresh)
            {
                this.Disable = true;
                this.Configuration.Enabled = false;
            }
        }
Example #5
0
 public MapLinker(
     DalamudPluginInterface pluginInterface,
     ChatGui chat,
     CommandManager commands,
     DataManager data,
     ClientState clientState,
     Framework framework,
     GameGui gameGui,
     TargetManager targetManager)
 {
     Interface      = pluginInterface;
     ClientState    = clientState;
     TargetManager  = targetManager;
     Framework      = framework;
     CommandManager = commands;
     DataManager    = data;
     ChatGui        = chat;
     GameGui        = gameGui;
     Aetherytes     = DataManager.GetExcelSheet <Aetheryte>(ClientState.ClientLanguage);
     AetherytesMap  = DataManager.GetExcelSheet <MapMarker>(ClientState.ClientLanguage);
     Config         = pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
     Config.Initialize(pluginInterface);
     CommandManager.AddHandler("/maplink", new CommandInfo(CommandHandler)
     {
         HelpMessage = "/maplink - open the maplink panel."
     });
     Gui = new PluginUi(this);
     ChatGui.ChatMessage += Chat_OnChatMessage;
 }
Example #6
0
 // Use this for initialization
 void Start()
 {
     //PhotonNetwork.ConnectUsingSettings("1.2");
     photonView = GetComponent <PhotonView>();
     PhotonNetwork.playerName = playerName;
     cg = FindObjectOfType <ChatGui>();
     versionText.text = "v " + version;
 }
Example #7
0
 private static void PrintChatError(ChatGui chat, string message)
 {
     chat.PrintChat(new XivChatEntry
     {
         MessageBytes = Encoding.UTF8.GetBytes(message),
         Type         = XivChatType.ErrorMessage,
     });
 }
Example #8
0
        public void LogError(string message, string detail_message = "")
        {
            //if (!Config.PrintError) return;
            var msg = $"[{Name}] {message}";

            PluginLog.LogError(detail_message == "" ? msg : detail_message);
            ChatGui.PrintError(msg);
        }
    public void StartChat()
    {
        ChatGui chatGui = Object.FindObjectOfType <ChatGui>();

        chatGui.UserName = this.idInput.get_text().Trim();
        chatGui.Connect();
        base.enabled = false;
        PlayerPrefs.SetString("NamePickUserName", chatGui.UserName);
    }
Example #10
0
    public void Start()
    {
        this.chatNewComponent = FindObjectOfType <ChatGui>();
        string prefsName = GameSettings2.LoadTempUser();

        if (!string.IsNullOrEmpty(prefsName))
        {
            this.idInput.text = prefsName;
        }
    }
Example #11
0
    public void StartChat()
    {
        ChatGui chatNewComponent = FindObjectOfType <ChatGui>();

        chatNewComponent.UserName = GameObject.FindGameObjectWithTag("UserData").GetComponent <UserData> ().UserName;
        chatNewComponent.Connect();
        enabled = false;

        PlayerPrefs.SetString(NamePickGui.UserNamePlayerPref, GameObject.FindGameObjectWithTag("UserData").GetComponent <UserData> ().UserName);
    }
Example #12
0
    public void StartChat()
    {
        ChatGui chatNewComponent = FindObjectOfType <ChatGui>();

        chatNewComponent.UserName = this.idInput.text.Trim();
        chatNewComponent.Connect();
        enabled = false;

        PlayerPrefs.SetString(NamePickGui.UserNamePlayerPref, chatNewComponent.UserName);
    }
    public void Start()
    {
        this.chatNewComponent = Object.FindObjectOfType <ChatGui>();
        string @string = PlayerPrefs.GetString("NamePickUserName");

        if (!string.IsNullOrEmpty(@string))
        {
            this.idInput.set_text(@string);
        }
    }
Example #14
0
    public void Start()
    {
        this.chatNewComponent = FindObjectOfType <ChatGui>();

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);

        if (!string.IsNullOrEmpty(prefsName))
        {
            this.idInput.text = prefsName;
        }
    }
Example #15
0
        public void LogError(string message)
        {
            if (!Config.PrintError)
            {
                return;
            }
            var msg = $"[{Name}] {message}";

            PluginLog.LogError(msg);
            ChatGui.PrintError(msg);
        }
Example #16
0
    public void StartChat()
    {
        ChatGui chatNewComponent = FindObjectOfType <ChatGui>();

        chatNewComponent.UserName = this.idInput.text.Trim();
        chatNewComponent.enabled  = true;
        enabled = false;
        this.AppIdInputPanel.gameObject.SetActive(false);
        this.NameInputPanel.gameObject.SetActive(false);

        PlayerPrefs.SetString(NamePickGui.UserNamePlayerPref, chatNewComponent.UserName);
    }
Example #17
0
    public void Start()
    {
        this.chatNewComponent = GetComponent <ChatGui>();
        this.photonManager    = GetComponent <PhotonManager>();

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);

        if (!string.IsNullOrEmpty(prefsName))
        {
            this.idInput.text = prefsName;
        }
    }
Example #18
0
        public Plugin(
            [RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
            [RequiredVersion("1.0")] CommandManager commandManager,
            ClientState clientState,
            SigScanner sigScanner,
            ChatGui chatGui)
        {
            PluginInterface = pluginInterface;
            CommandManager  = commandManager;

            Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();

            Interface = new Interface();

            Commands.Add((s, t) => Interface.Show(), "/customize", "Opens the customize plus window");

            PluginInterface.UiBuilder.Draw         += Interface.Draw;
            PluginInterface.UiBuilder.OpenConfigUi += Interface.Show;

            this.clientState = clientState;

            try
            {
                // "Render::Manager::Render"
                renderManagerHook = new Hook <RenderDelegate>(sigScanner.ScanText("40 53 55 57 41 56 41 57 48 83 EC 60"), manager =>
                {
                    // if this gets disposed while running we crash calling Original's getter, so get it at start
                    var original = renderManagerHook.Original;
                    try
                    {
                        if (!updateFailed)
                        {
                            Update();
                        }
                    }
                    catch (Exception e)
                    {
                        chatGui.PrintError("Failed to run CustomizePlus render hook, disabling.");
                        PluginLog.Error($"Error in CustomizePlus render hook {e}");

                        updateFailed = true;
                    }

                    return(original(manager));
                });
                // Because scales all get set to 0 below, the character will be very messed up
                renderManagerHook.Enable();
            }
            catch (Exception e)
            {
                PluginLog.Error($"Failed to hook Render::Manager::Render {e}");
            }
        }
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else if (instance != this)
     {
         Debug.LogWarning("Destroying duplicate instance of "+this.gameObject+". ChatGui applies DontDestroyOnLoad() to this GameObject.");
         Destroy(this.gameObject);
     }
 }
Example #20
0
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(this.gameObject);
     }
     else if (instance != this)
     {
         Debug.LogWarning("Destroying duplicate instance of " + this.gameObject + ". ChatGui applies DontDestroyOnLoad() to this GameObject.");
         Destroy(this.gameObject);
     }
 }
Example #21
0
	// ----------------------------------------------------------------------------------------------------------------
	#region start / init

	void Start()
	{
		rectWindow.x = Screen.width / 2 - rectWindow.width / 2;
		rectWindow.y = 100; // Screen.height / 2 - rectWindow.height / 2;

		chat = gameObject.GetComponent<ChatGui>();

		state = State.waiting;
		simple_console_text = "Contacting master server ...";
		waitMsg = "Please wait, contacting game servers";
		// contact the master server and wait for a reply send to OnMasterServerReply
		StartCoroutine(SDNet.Instance.ContactMasterServer(OnNetMasterServerReply));
	}
Example #22
0
    public void Start()
    {
        this.chatNewComponent = FindObjectOfType<ChatGui>();

        bool appIdMissing = false; // string.IsNullOrEmpty(ChatSettings.Instance.AppId);
        this.AppIdInputPanel.gameObject.SetActive(appIdMissing);
        this.NameInputPanel.gameObject.SetActive(!appIdMissing);

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);
        if (!string.IsNullOrEmpty(prefsName))
        {
            this.idInput.text = prefsName;
        }
    }
Example #23
0
    public void Start()
    {
        this.chatNewComponent = FindObjectOfType <ChatGui>();

        bool appIdMissing = false; // string.IsNullOrEmpty(ChatSettings.Instance.AppId);

        this.AppIdInputPanel.gameObject.SetActive(appIdMissing);
        this.NameInputPanel.gameObject.SetActive(!appIdMissing);

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);

        if (!string.IsNullOrEmpty(prefsName))
        {
            this.idInput.text = prefsName;
        }
    }
Example #24
0
    // Use this for initialization
    void Start()
    {
        photonView = GetComponent <PhotonView>();
        sm         = FindObjectOfType <ScoreManager>();
        bm         = FindObjectOfType <BoardManager>();
        dm         = FindObjectOfType <DeckManager>();
        cc         = FindObjectOfType <ChatGui>();

        playerName = PhotonNetwork.playerName;
        if (playerName.CompareTo(PhotonNetwork.playerList[0].name) != 0)
        {
            enemyName = PhotonNetwork.playerList[0].name;
        }
        else
        {
            enemyName = PhotonNetwork.playerList[1].name;
        }
        if (PhotonNetwork.isMasterClient)
        {
            int n = Random.Range(0, 2);
            setStartPlayer(n);
            photonView.RPC("setStartPlayer", PhotonTargets.Others, 1 - n);
            if (turn.CompareTo("Player") == 0)
            {
                mainText.text = playerName + " begins";
            }
            else
            {
                mainText.text = enemyName + " begins";
            }
        }
        playerLife          = 2;
        enemyLife           = 2;
        playerNameText.text = playerName;
        enemyNameText.text  = enemyName;
        mainText.enabled    = false;
        playerPass          = true;
        enemyPass           = true;
        nr = true;
        passButton.interactable  = false;
        passedTextPlayer.enabled = false;
        passedTextEnemy.enabled  = false;

        factionPlayer          = DeckBuilder.factions[DeckBuilder.selectedFaction];
        factionTextPlayer.text = factionPlayer;
        photonView.RPC("sendFaction", PhotonTargets.Others, factionPlayer);
    }
        private void OnCommand(string command, string arguments)
        {
            if (command.ToLower() != "/sc")
            {
                return;
            }
            byte[] rndSeries = new byte[4];
            _csp.GetBytes(rndSeries);
            int rnd = (int)Math.Abs(BitConverter.ToUInt32(rndSeries, 0) / _base * 50 + 1);

            ChatGui.Print(_config.IsEnabled
                ? $"sancheck: 1d100={rnd + 50}, Failed"
                : $"sancheck: 1d100={rnd}, Passed");
            _config.IsEnabled = !_config.IsEnabled;
            SetEnabled(_config.IsEnabled);
            Interface.SavePluginConfig(_config);
        }
Example #26
0
        public Plugin(DalamudPluginInterface pluginInterface, ChatGui chat, Framework framework, CommandManager commands, SigScanner sigScanner)
        {
            this.pluginInterface = pluginInterface;
            this.chat            = chat;
            this.framework       = framework;
            this.sigScanner      = sigScanner;

            config = this.pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            config.Initialize(this.pluginInterface);

            // this.ui = new PluginUI();
            // this.pluginInterface.UiBuilder.OnBuildUi += this.ui.Draw;

            framework.Update += Update;

            commandManager = new PluginCommandManager <Plugin>(this, commands);

            InitializePointers();
        }
Example #27
0
    public void Start()
    {
        if (instance == null)
        {
            instance = this;
            // DontDestroyOnLoad(gameObject);
        }
        //  else
        // {
        //   Destroy(this.gameObject);
        // }


        UserIdText.text = UserDetailsManager.userName.ToLower();
        StateText.text  = "";
        StateText.gameObject.SetActive(true);
        UserIdText.gameObject.SetActive(true);
        Title.SetActive(true);
        ChatPanel.gameObject.SetActive(false);
        ConnectingLabel.SetActive(false);

        if (string.IsNullOrEmpty(UserName))
        {
            UserName = "******" + Environment.TickCount % 99;           //made-up username
        }
        Debug.Log("CHATTTTTTTID" + UserDetailsManager.PhotonChatID);

        bool _AppIdPresent = string.IsNullOrEmpty(UserDetailsManager.PhotonChatID);

        this.missingAppIdErrorPanel.SetActive(_AppIdPresent);

        this.UserIdFormPanel.gameObject.SetActive(!_AppIdPresent);

        if (string.IsNullOrEmpty(UserDetailsManager.PhotonChatID))
        {
            Debug.LogError("You need to set the chat app ID in the PhotonServerSettings file in order to continue.");
            return;
        }
        Connect();
    }
Example #28
0
    public void Awake()
    {
        this.guiCenteredRect = new Rect(Screen.width/2-GuiSize.x/2, Screen.height/2-GuiSize.y/4, GuiSize.x, GuiSize.y);
        this.chatComponent = this.GetComponent<ChatGui>();

        if (this.chatComponent != null && chatComponent.enabled)
        {
            Debug.LogWarning("When using the NamePickGui, ChatGui should be disabled initially.");
            
            if (this.chatComponent.chatClient != null)
            {
                this.chatComponent.chatClient.Disconnect();
            }
            this.chatComponent.enabled = false;
        }

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);
        if (!string.IsNullOrEmpty(prefsName))
        {
            this.InputLine = prefsName;
        }
    }
Example #29
0
        public void WhitelistTargetPlayer(string command, string arguments)
        {
            if (ObjectTable.SingleOrDefault(
                    x => x is PlayerCharacter &&
                    x.ObjectId != 0 &&
                    x.ObjectId != ClientState.LocalPlayer?.ObjectId &&
                    x.ObjectId == ClientState.LocalPlayer?.TargetObjectId) is PlayerCharacter
                actor)
            {
                var item = new VoidItem(actor, arguments, false);

                var playerString = Encoding.UTF8.GetString(
                    new SeString(
                        new TextPayload(actor.Name.TextValue),
                        new IconPayload(BitmapFontIcon.CrossWorld),
                        new TextPayload(actor.HomeWorld.GameData !.Name)).Encode());

                if (!this.Configuration.Whitelist.Any(
                        x =>
                        x.Name == item.Name && x.HomeworldId == item.HomeworldId))
                {
                    this.Configuration.Whitelist.Add(item);
                    this.Configuration.Save();
                    this.ShowPlayer(actor.ObjectId);
                    ChatGui.Print(
                        this.PluginLocalization.EntryAdded(this.PluginLocalization.WhitelistName, playerString));
                }
                else
                {
                    ChatGui.Print(
                        this.PluginLocalization.EntryExistsError(this.PluginLocalization.WhitelistName, playerString));
                }
            }
            else
            {
                ChatGui.Print(
                    this.PluginLocalization.InvalidTargetError(this.PluginLocalization.WhitelistName));
            }
        }
Example #30
0
    public void Start()
    {
        DontDestroyOnLoad(this.gameObject);
        Application.runInBackground = true; // this must run in background or it will drop connection if not focussed.

        if (string.IsNullOrEmpty(this.UserName))
        {
            if (dev)
            {
                this.UserName = "******";
            }
            else
            {
                this.UserName = "******" + Environment.TickCount % 99; //made-up username
            }
        }
        cc = FindObjectOfType <ChatGui>();
        if (cc == this)
        {
            chatClient = new ChatClient(this);
            //chatClient.Connect(ChatAppId, "1.2", this.UserName, null);
        }
        else
        {
            Destroy(this);
        }


        if (this.FullScreen)
        {
            this.GuiRect.x      = 0;
            this.GuiRect.y      = 0;
            this.GuiRect.width  = Screen.width;
            this.GuiRect.height = Screen.height;
        }

        Debug.Log(this.UserName);
    }
Example #31
0
    public void Awake()
    {
        this.guiCenteredRect = new Rect(Screen.width / 2 - GuiSize.x / 2, Screen.height / 2 - GuiSize.y / 4, GuiSize.x, GuiSize.y);
        this.chatComponent   = this.GetComponent <ChatGui>();

        if (this.chatComponent != null && chatComponent.enabled)
        {
            Debug.LogWarning("When using the NamePickGui, ChatGui should be disabled initially.");

            if (this.chatComponent.chatClient != null)
            {
                this.chatComponent.chatClient.Disconnect();
            }
            this.chatComponent.enabled = false;
        }

        string prefsName = PlayerPrefs.GetString(NamePickGui.UserNamePlayerPref);

        if (!string.IsNullOrEmpty(prefsName))
        {
            this.InputLine = prefsName;
        }
    }
Example #32
0
        public Plugin(
            DalamudPluginInterface dalamudPluginInterface,
            DCommandManager commandManager,
            ChatGui chatGui,
            ClientState clientState,
            Condition condition)
        {
            PluginInterface = dalamudPluginInterface;
            ChatGui         = chatGui;
            ClientState     = clientState;
            Condition       = condition;

            Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
            Configuration.Initialize(dalamudPluginInterface);

            RemoteConfigManager = new RemoteManager(this);
            var config = RemoteConfigManager.Config;

            Version =
                $"FP{VersionInfo.VersionNum}{VersionInfo.Type}_SP{Spotify.VersionInfo.VersionNum}{Spotify.VersionInfo.Type}_HX{config.ApiVersion}";

            commandManager.AddHandler(Command, new CommandInfo(OnCommand)
            {
                HelpMessage = "Run commands for Fantasy Player"
            });

            //Setup player
            PlayerManager = new PlayerManager(this);

            FPCommandManager = new FPCommandManager(dalamudPluginInterface, this);

            InterfaceController = new InterfaceController(this);

            PluginInterface.UiBuilder.Draw         += InterfaceController.Draw;
            PluginInterface.UiBuilder.OpenConfigUi += OpenConfig;
        }
Example #33
0
    public void OnPointerClick(PointerEventData eventData)
    {
        ChatGui chatGui = Object.FindObjectOfType <ChatGui>();

        chatGui.ShowChannel(this.Channel);
    }
Example #34
0
    public void OnPointerClick(PointerEventData eventData)
    {
        ChatGui handler = FindObjectOfType <ChatGui>();

        handler.ShowChannel(this.Channel);
    }