Exemplo n.º 1
0
 GameScreen ConvertDialog(Game game, Packet_Dialog p)
 {
     DialogScreen s = new DialogScreen();
     s.widgets = new MenuWidget[p.WidgetsCount];
     s.WidgetCount = p.WidgetsCount;
     for (int i = 0; i < p.WidgetsCount; i++)
     {
         Packet_Widget a = p.Widgets[i];
         MenuWidget b = new MenuWidget();
         if (a.Type == Packet_WidgetTypeEnum.Text)
         {
             b.type = WidgetType.Label;
         }
         if (a.Type == Packet_WidgetTypeEnum.Image)
         {
             b.type = WidgetType.Button;
         }
         if (a.Type == Packet_WidgetTypeEnum.TextBox)
         {
             b.type = WidgetType.Textbox;
         }
         b.x = a.X;
         b.y = a.Y;
         b.sizex = a.Width;
         b.sizey = a.Height_;
         b.text = a.Text;
         if (b.text != null)
         {
             b.text = game.platform.StringReplace(b.text, "!SERVER_IP!", game.ServerInfo.connectdata.Ip);
         }
         if (b.text != null)
         {
             b.text = game.platform.StringReplace(b.text, "!SERVER_PORT!", game.platform.IntToString(game.ServerInfo.connectdata.Port));
         }
         b.color = a.Color;
         if (a.Font != null)
         {
             b.font = new FontCi();
             b.font.family = game.ValidFont(a.Font.FamilyName);
             b.font.size = game.DeserializeFloat(a.Font.SizeFloat);
             b.font.style = a.Font.FontStyle;
         }
         b.id = a.Id;
         b.isbutton = a.ClickKey != 0;
         if (a.Image == "Solid")
         {
             b.image = null;
         }
         else if (a.Image != null)
         {
             b.image = StringTools.StringAppend(game.platform, a.Image, ".png");
         }
         s.widgets[i] = b;
     }
     for (int i = 0; i < s.WidgetCount; i++)
     {
         if (s.widgets[i] == null) { continue; }
         if (s.widgets[i].type == WidgetType.Textbox)
         {
             s.widgets[i].editing = true;
             break;
         }
     }
     return s;
 }
Exemplo n.º 2
0
    GameScreen ConvertDialog(Game game, Packet_Dialog p)
    {
        DialogScreen s = new DialogScreen();

        s.widgets     = new MenuWidget[p.WidgetsCount];
        s.WidgetCount = p.WidgetsCount;
        for (int i = 0; i < p.WidgetsCount; i++)
        {
            Packet_Widget a = p.Widgets[i];
            MenuWidget    b = new MenuWidget();
            if (a.Type == Packet_WidgetTypeEnum.Text)
            {
                b.type = WidgetType.Label;
            }
            if (a.Type == Packet_WidgetTypeEnum.Image)
            {
                b.type = WidgetType.Button;
            }
            if (a.Type == Packet_WidgetTypeEnum.TextBox)
            {
                b.type = WidgetType.Textbox;
            }
            b.x     = a.X;
            b.y     = a.Y;
            b.sizex = a.Width;
            b.sizey = a.Height_;
            b.text  = a.Text;
            if (b.text != null)
            {
                b.text = game.platform.StringReplace(b.text, "!SERVER_IP!", game.ServerInfo.connectdata.Ip);
            }
            if (b.text != null)
            {
                b.text = game.platform.StringReplace(b.text, "!SERVER_PORT!", game.platform.IntToString(game.ServerInfo.connectdata.Port));
            }
            b.color = a.Color;
            if (a.Font != null)
            {
                b.font        = new FontCi();
                b.font.family = game.ValidFont(a.Font.FamilyName);
                b.font.size   = game.DeserializeFloat(a.Font.SizeFloat);
                b.font.style  = a.Font.FontStyle;
            }
            b.id       = a.Id;
            b.isbutton = a.ClickKey != 0;
            if (a.Image == "Solid")
            {
                b.image = null;
            }
            else if (a.Image != null)
            {
                b.image = StringTools.StringAppend(game.platform, a.Image, ".png");
            }
            s.widgets[i] = b;
        }
        for (int i = 0; i < s.WidgetCount; i++)
        {
            if (s.widgets[i] == null)
            {
                continue;
            }
            if (s.widgets[i].type == WidgetType.Textbox)
            {
                s.widgets[i].editing = true;
                break;
            }
        }
        return(s);
    }