Exemplo n.º 1
0
        internal void InitWithUIResource(UIResource resource)
        {
            ClearComponents();

             for (int i = 0; i < resource.Labels.Count; i++)
             {
            WinWarCS.Data.Resources.UIResource.UIEntry me = resource.Labels[i];

            UILabel label = new UILabel(me.Text);
            label.X = (int)me.X;
            label.Y = (int)me.Y;
            label.TextAlign = (TextAlignHorizontal)me.Alignment;
            AddComponent(label);
             }

             for (int i = 0; i < resource.Elements.Count; i++)
             {
            WinWarCS.Data.Resources.UIResource.UIEntry me = resource.Elements[i];

            if (me.Type == UIResource.UIEntryType.ValueList)
            {
               UILabel lbl = new UILabel(me.Values[0]);
               lbl.X = (int)(me.X);
               lbl.Y = (int)(me.Y);
               lbl.TextAlign = (TextAlignHorizontal)me.Alignment;
               AddComponent(lbl);
            }
            else
            {
               UIButton btn = new UIButton(me.Text, me.ButtonReleasedResourceIndex, me.ButtonPressedResourceIndex);
               btn.X = (int)(me.X);
               btn.Y = (int)(me.Y);
               AddComponent(btn);
            }
             }
        }
Exemplo n.º 2
0
        private void ShowSingleUI()
        {
            // Fail-safe
             if (currentEntities.Length != 1)
            return;

             SpriteResource res = WarFile.GetSpriteResource(race == Race.Humans ? 360 : 359);
             SpriteResource resUnit = WarFile.GetSpriteResource(361);

             Entity ent = currentEntities[0];

             UISpriteImage unitFrame = new UISpriteImage(new Sprite(res));
             unitFrame.FixedSpriteFrame = ent.Mana > 0 ? 1 : 0;
             unitFrame.X = 0;
             unitFrame.Y = 0;
             AddComponent(unitFrame);

             UISpriteImage unitIcon = new UISpriteImage(new Sprite(resUnit));
             unitIcon.FixedSpriteFrame = ent.IconIndex;
             unitIcon.X = 4;
             unitIcon.Y = 4;
             unitFrame.AddComponent(unitIcon);

             UILabel nameLabel = new UILabel(currentEntities[0].Name);
             nameLabel.TextAlign = TextAlignHorizontal.Left;
             nameLabel.X = 4;
             nameLabel.Y = unitIcon.Y + unitIcon.Height + 2;
             unitFrame.AddComponent(nameLabel);

             UIImage img = new UIImage(null);
             img.X = 35;
             img.Y = 20;
             img.Height = 3;
             img.BackgroundColor = new Color(0.0f, 1.0f, 0.0f, 1.0f);
             SetHealthbar(img, ent);
             unitFrame.AddComponent(img);

             healthBars.Add(ent, img);
        }
Exemplo n.º 3
0
        private void InitUI()
        {
            ClearComponents ();

             MapControl = new UIMapControl();
             MapControl.OnSelectedEntitiesChanged += HandleOnSelectedEntitiesChanged;
             AddComponent (MapControl);

             EntityControl = new UIEntityControl(LevelGameScreen.Game.UIRace);
             MinimapControl = new UIMinimapControl(MapControl);

             LoadUIImage (ref leftSidebarTop, "Sidebar Left Minimap Black (" + LevelGameScreen.Game.UIRace + ")");
             LoadUIImage (ref leftSidebar, "Sidebar Left (" + LevelGameScreen.Game.UIRace + ")");
             leftSidebar.Y = leftSidebarTop.Height;

             LoadUIImage (ref topBar, "Topbar (" + LevelGameScreen.Game.UIRace + ")");
             LoadUIImage (ref bottomBar, "Lower Bar (" + LevelGameScreen.Game.UIRace + ")");

             topBar.X = leftSidebarTop.Width;
             bottomBar.X = leftSidebar.Width;
             bottomBar.Y = 200 - bottomBar.Height;

             LoadUIImage (ref rightBar, "Sidebar Right (" + LevelGameScreen.Game.UIRace + ")");
             rightBar.X = 320 - rightBar.Width;

             MapControl.X = leftSidebarTop.Width;
             MapControl.Y = topBar.Height;
             MapControl.Width = rightBar.X - MapControl.X;
             MapControl.Height = bottomBar.Y - MapControl.Y;

             MinimapControl.X = 3;
             MinimapControl.Y = 6;
             MinimapControl.Width = 64;
             MinimapControl.Height = 64;
             MinimapControl.BackgroundColor = Color.AliceBlue;
             MinimapControl.Init ();

             menuButton = new UIButton ("", WarFile.KnowledgeBase.IndexByName("Menu Button"), WarFile.KnowledgeBase.IndexByName("Menu Button (Pressed)"));
             menuButton.X = leftSidebar.Width / 2 - menuButton.Width / 2 - 1;
             menuButton.Y = leftSidebarTop.Height + leftSidebar.Height - menuButton.Height - 1;
             menuButton.OnMouseUpInside += menuButton_OnMouseUpInside;
             AddComponent (menuButton);

             EntityControl.X = 2;
             EntityControl.Y = MinimapControl.Y + MinimapControl.Height + 2;
             EntityControl.Width = 64;
             EntityControl.Height = MainGame.OriginalAppHeight - EntityControl.Y - menuButton.Height - 2;

             lumberLabel = new UILabel ("Lumber:");
             lumberLabel.X = 95;
             lumberLabel.Y = 0;
             lumberLabel.Width = 72;
             lumberLabel.Height = 10;
             lumberLabel.TextAlign = TextAlignHorizontal.Left;
             AddComponent (lumberLabel);

             lumberValueLabel = new UILabel ("1000");
             lumberValueLabel.X = 95;
             lumberValueLabel.Y = 0;
             lumberValueLabel.Width = 72;
             lumberValueLabel.Height = 10;
             lumberValueLabel.TextAlign = TextAlignHorizontal.Right;
             AddComponent (lumberValueLabel);

             goldLabel = new UILabel ("Gold:");
             goldLabel.X = 206;
             goldLabel.Y = 0;
             goldLabel.Width = 60;
             goldLabel.Height = 10;
             goldLabel.TextAlign = TextAlignHorizontal.Left;
             AddComponent (goldLabel);

             goldValueLabel = new UILabel ("1000");
             goldValueLabel.X = 206;
             goldValueLabel.Y = 0;
             goldValueLabel.Width = 60;
             goldValueLabel.Height = 10;
             goldValueLabel.TextAlign = TextAlignHorizontal.Right;
             AddComponent (goldValueLabel);

             AddComponent (MinimapControl);
             AddComponent (EntityControl);
        }