Example #1
0
            public TextdrawHUD(Player player)
            {
                layer = new TextdrawLayer();
                string filename = BaseMode.Instance.Client.ServerPath + "\\scriptfiles\\tdcreator.json";
                string jsonData = "";

                if (File.Exists(filename))
                {
                    try
                    {
                        using (FileStream fs = File.Open(filename, FileMode.Open, FileAccess.Read))
                        {
                            byte[] output      = new byte[fs.Length];
                            int    idx         = 0;
                            int    blockLength = 1;
                            byte[] tmp         = new byte[blockLength];
                            int    readBytes;
                            while ((readBytes = fs.Read(tmp, 0, blockLength)) > 0)
                            {
                                for (int i = 0; i < readBytes; i++)
                                {
                                    output[idx + i] = tmp[i];
                                }
                                idx += readBytes;
                            }
                            jsonData = new UTF8Encoding(true).GetString(output);
                            List <textdraw> textdraws = JsonConvert.DeserializeObject <List <textdraw> >(jsonData);
                            foreach (textdraw textdraw in textdraws)
                            {
                                if (textdraw.Type.Equals("box"))
                                {
                                    layer.CreateTextdraw(player, textdraw.Name, TextdrawLayer.TextdrawType.Box);
                                    layer.SetTextdrawPosition(textdraw.Name, new Vector2(textdraw.PosX, textdraw.PosY));
                                    layer.SetTextdrawSize(textdraw.Name, textdraw.Width, textdraw.Height);
                                }
                                if (textdraw.Type.Equals("text"))
                                {
                                    layer.CreateTextdraw(player, textdraw.Name, TextdrawLayer.TextdrawType.Text);
                                    layer.SetTextdrawPosition(textdraw.Name, new Vector2(textdraw.PosX, textdraw.PosY));
                                }
                            }
                            layer.SetTextdrawText("layer", "Layer: None");
                            layer.SetTextdrawText("tdselected", "TD: None");
                            layer.SetTextdrawText("tdmode", "Mode: None");
                            layer.UnselectAllTextdraw();
                            fs.Close();
                        }
                    }
                    catch (IOException e)
                    {
                        Console.WriteLine("TextdrawCreator.cs - TextdrawHUD._:E: Cannot load Textdraw HUD:");
                        Console.WriteLine(e.Message);
                    }
                }
            }
Example #2
0
 public void Destroy()
 {
     layer.HideAll();
     layer = null;
 }