Esempio n. 1
0
 void OnUseEntity(int player, int chunkx, int chunky, int chunkz, int id)
 {
     ServerEntity e = server.GetEntity(chunkx, chunky, chunkz, id);
     if (e.sign == null)
     {
         return;
     }
     if (!server.CheckBuildPrivileges(player, (int)e.position.x, (int)e.position.z, (int)e.position.y))
     {
         return;
     }
     ManicDigger.Dialog d = new ManicDigger.Dialog();
     d.Width = 400;
     d.Height = 200;
     d.IsModal = true;
     d.Widgets = new ManicDigger.Widget[4];
     int widgetCount = 0;
     var font = new DialogFont("Verdana", 11f, DialogFontStyle.Bold);
     d.Widgets[widgetCount++] = Widget.MakeSolid(0, 0, 300, 200, Game.ColorFromArgb(255, 50, 50, 50));
     d.Widgets[widgetCount++] = Widget.MakeTextBox(e.sign.text, font, 50, 50, 200, 50, Game.ColorFromArgb(255, 0, 0, 0));
     Widget okHandler = Widget.MakeSolid(100, 100, 100, 50, Game.ColorFromArgb(255, 100, 100, 100));
     okHandler.ClickKey = (char)13;
     okHandler.Id = "UseSign_OK";
     d.Widgets[widgetCount++] = okHandler;
     d.Widgets[widgetCount++] = Widget.MakeText("OK", font, 100, 100, Game.ColorFromArgb(255, 0, 0, 0));
     ServerEntityId id_ = new ServerEntityId();
     id_.chunkx = chunkx;
     id_.chunky = chunky;
     id_.chunkz = chunkz;
     id_.id = id;
     server.clients[player].editingSign = id_;
     server.SendDialog(player, "UseSign", d);
 }
Esempio n. 2
0
        public static Widget MakeText(string text, DialogFont Font, float x, float y, int textColor)
        {
            Widget w = new Widget();

            w.Type  = WidgetType.Text;
            w.Text  = text;
            w.X     = (int)x;
            w.Y     = (int)y;
            w.Font  = Font;
            w.Color = textColor;
            return(w);
        }
Esempio n. 3
0
        public static Widget MakeTextBox(string text, DialogFont Font, float x, float y, float width, float height, int textColor)
        {
            Widget w = new Widget();

            w.Type   = WidgetType.TextBox;
            w.Text   = text;
            w.X      = (int)x;
            w.Y      = (int)y;
            w.Width  = (int)width;
            w.Height = (int)height;
            w.Font   = Font;
            w.Color  = textColor;
            return(w);
        }
Esempio n. 4
0
 public float[] MeasureTextSize(string text, DialogFont font)
 {
     if (IsArm)
     {
         // fixes crash
         return(new float[] { text.Length * 1f *font.Size, 1.7f *font.Size });
     }
     else
     {
         using (Bitmap bmp = new Bitmap(1, 1))
         {
             using (Graphics g = Graphics.FromImage(bmp))
             {
                 SizeF size = g.MeasureString(text, new System.Drawing.Font(font.FamilyName, font.Size, (FontStyle)font.FontStyle), new PointF(0, 0), new StringFormat(StringFormatFlags.MeasureTrailingSpaces));
                 return(new float[] { size.Width, size.Height });
             }
         }
     }
 }
Esempio n. 5
0
 public float[] MeasureTextSize(string text, DialogFont font)
 {
     if (IsArm)
     {
         // fixes crash
         return(new float[] { text.Length * 1f *font.Size, 1.7f *font.Size });
     }
     using (Bitmap bmp = new Bitmap(1, 1))
     {
         using (Graphics g = Graphics.FromImage(bmp))
         {
             g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
             Font         tmpFont   = new Font(font.FamilyName, font.Size, (FontStyle)font.FontStyle);
             StringFormat tmpFormat = new StringFormat(StringFormatFlags.MeasureTrailingSpaces);
             SizeF        size      = g.MeasureString(StripColorCodes(text), tmpFont, new PointF(0, 0), tmpFormat);
             return(new float[] { size.Width, size.Height });
         }
     }
 }
Esempio n. 6
0
        public float[] MeasureTextSize(string text, DialogFont font)
        {
            if (IsArm)
            {
                // fixes crash
                return(new float[] { text.Length * 1f *font.Size, 1.7f *font.Size });
            }
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < text.Length; i++)
            {
                if (text[i] == '&')
                {
                    if (i + 1 < text.Length && isCharHex(text[i + 1]))
                    {
                        i++;
                    }
                    else
                    {
                        builder.Append(text[i]);
                    }
                }
                else
                {
                    builder.Append(text[i]);
                }
            }
            using (Bitmap bmp = new Bitmap(1, 1))
            {
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    SizeF size = g.MeasureString(builder.ToString(), new System.Drawing.Font(font.FamilyName, font.Size, (FontStyle)font.FontStyle), new PointF(0, 0), new StringFormat(StringFormatFlags.MeasureTrailingSpaces));
                    return(new float[] { size.Width, size.Height });
                }
            }
        }
Esempio n. 7
0
 public float[] MeasureTextSize(string text, DialogFont font)
 {
     if (IsArm)
     {
         // fixes crash
         return new float[] { text.Length * 1f * font.Size, 1.7f * font.Size };
     }
     else
     {
         using (Bitmap bmp = new Bitmap(1, 1))
         {
             using (Graphics g = Graphics.FromImage(bmp))
             {
                 SizeF size = g.MeasureString(text, new System.Drawing.Font(font.FamilyName, font.Size, (FontStyle)font.FontStyle), new PointF(0, 0), new StringFormat(StringFormatFlags.MeasureTrailingSpaces));
                 return new float[] { size.Width, size.Height };
             }
         }
     }
 }
Esempio n. 8
0
 public static Widget MakeTextBox(string text, DialogFont Font, float x, float y, float width, float height, int textColor)
 {
     Widget w = new Widget();
     w.Type = WidgetType.TextBox;
     w.Text = text;
     w.X = (int)x;
     w.Y = (int)y;
     w.Width = (int)width;
     w.Height = (int)height;
     w.Font = Font;
     w.Color = textColor;
     return w;
 }
Esempio n. 9
0
 public static Widget MakeText(string text, DialogFont Font, float x, float y, int textColor)
 {
     Widget w = new Widget();
     w.Type = WidgetType.Text;
     w.Text = text;
     w.X = (int)x;
     w.Y = (int)y;
     w.Font = Font;
     w.Color = textColor;
     return w;
 }
Esempio n. 10
0
 void OnUseEntity(int player, int chunkx, int chunky, int chunkz, int id)
 {
     ServerEntity e = server.GetEntity(chunkx, chunky, chunkz, id);
     if (e.permissionSign == null)
     {
         return;
     }
     if (!server.PlayerHasPrivilege(player, ServerClientMisc.Privilege.area_add))
     {
         server.SendMessage(player, server.colorError + server.language.Get("Server_CommandInsufficientPrivileges"));
         return;
     }
     ManicDigger.Dialog d = new ManicDigger.Dialog();
     d.Width = 400;
     d.Height = 400;
     d.IsModal = true;
     d.Widgets = new ManicDigger.Widget[4 + server.serverClient.Groups.Count * 2];
     int widgetCount = 0;
     var font = new DialogFont("Verdana", 11f, DialogFontStyle.Bold);
     d.Widgets[widgetCount++] = Widget.MakeSolid(0, 0, 400, 400, Game.ColorFromArgb(255, 50, 50, 50));
     d.Widgets[widgetCount++] = Widget.MakeTextBox(e.permissionSign.name, font, 50, 50, 200, 50, Game.ColorFromArgb(255, 0, 0, 0));
     for (int i = 0; i < server.serverClient.Groups.Count; i++)
     {
         Group g = server.serverClient.Groups[i];
         Widget button = Widget.MakeSolid(50, 150 + i * 50, 100, 40, Game.ColorFromArgb(255, 100, 100, 100));
         button.ClickKey = (char)13;
         button.Id = "PermissionSignGroup" + g.Name;
         d.Widgets[widgetCount++] = button;
         d.Widgets[widgetCount++] = Widget.MakeText(g.Name, font, 50, 150 + i * 50, Game.ColorFromArgb(255, 0, 0, 0));
     }
     Widget okHandler = Widget.MakeSolid(200, 50, 100, 50, Game.ColorFromArgb(255, 100, 100, 100));
     okHandler.ClickKey = (char)13;
     okHandler.Id = "UsePermissionSign_OK";
     d.Widgets[widgetCount++] = okHandler;
     d.Widgets[widgetCount++] = Widget.MakeText("Set player", font, 200, 50, Game.ColorFromArgb(255, 0, 0, 0));
     ServerEntityId id_ = new ServerEntityId();
     id_.chunkx = chunkx;
     id_.chunky = chunky;
     id_.chunkz = chunkz;
     id_.id = id;
     server.clients[player].editingSign = id_;
     server.SendDialog(player, "UseSign", d);
 }