Exemple #1
0
        /// <summary>
        /// Called if loading the resources has been finished.
        /// </summary>
        private void LoadingFinished(IUIBackgroundTask sender, object args)
        {
            this.loadingTask.Finished -= this.LoadingFinished;
            this.loadingTask.Failed   -= this.LoadingFailed;

            if (this.LoadFinished != null)
            {
                this.LoadFinished();
            }

            this.loadingTask  = null;
            this.currentPhase = ShowPhase.Normal;
            UIWorkspace.Instance.SetDefaultMousePointer(UIResourceManager.GetResource <UIPointer>("RC.App.Pointers.NormalPointer"));

            UIFont menuFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B");

            string[] menuPoints = new string[3] {
                START_GAME_MENUPOINT, CREDITS_MENUPOINT, EXIT_MENUPOINT
            };
            this.menuPanel = new RCMainMenuPanel(new RCIntRectangle((UIWorkspace.Instance.WorkspaceSize.X - MENU_PANEL_WIDTH) / 2,
                                                                    100,
                                                                    MENU_PANEL_WIDTH,
                                                                    (menuFont.CharTopMaximum + menuFont.CharBottomMaximum + 1) * menuPoints.Length),
                                                 menuPoints);
            this.RegisterPanel(this.menuPanel);

            this.menuPanel[START_GAME_MENUPOINT].Pressed += this.OnMenupointPressed;
            this.menuPanel[CREDITS_MENUPOINT].Pressed    += this.OnMenupointPressed;
            this.menuPanel[EXIT_MENUPOINT].Pressed       += this.OnMenupointPressed;

            this.menuPanel.Show();
        }
Exemple #2
0
        public MySensitiveObject(RCIntVector position,
                                 RCIntRectangle range,
                                 string name,
                                 RCColor basicColor,
                                 RCColor highColor)
            : base(position, range)
        {
            this.nameStrBasic    = new UIString(name, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6"), new RCIntVector(2, 2), RCColor.WhiteHigh);
            this.nameStrHigh     = new UIString(name, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6"), new RCIntVector(2, 2), RCColor.LightRed);
            this.backgroundBasic = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(basicColor, this.Range.Size, new RCIntVector(2, 2));
            this.backgroundHigh  = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(highColor, this.Range.Size, new RCIntVector(2, 2));

            this.backgroundBasic.Upload();
            this.backgroundHigh.Upload();

            this.name          = name;
            this.isHighlighted = false;
            this.activatorBtn  = UIMouseButton.Undefined;

            this.MouseSensor.Enter      += this.OnEnter;
            this.MouseSensor.Leave      += this.OnLeave;
            this.MouseSensor.ButtonDown += this.OnButtonDown;
            this.MouseSensor.ButtonUp   += this.OnButtonUp;
            this.MouseSensor.Wheel      += this.OnWheel;
            this.MouseSensor.Move       += this.OnMove;
        }
 /// <summary>
 /// Constructs an RCObjectPlacementDisplay extension for the given map display control.
 /// </summary>
 /// <param name="extendedControl">The map display control to extend.</param>
 public RCObjectPlacementDisplay(RCMapDisplay extendedControl)
     : base(extendedControl)
 {
     this.objectPlacementMaskGreen = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ObjectPlacementMaskGreen");
     this.objectPlacementMaskRed   = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ObjectPlacementMaskRed");
     this.lastKnownMousePosition   = RCIntVector.Undefined;
 }
        /// <summary>
        /// Constructs a details panel.
        /// </summary>
        /// <param name="productIconSprites">The product icon sprite group.</param>
        /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
        /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
        /// <param name="backgroundSprite">Name of the sprite resource that will be the background of this panel or null if there is no background.</param>
        public RCDetailsPanel(ISpriteGroup productIconSprites, RCIntRectangle backgroundRect, RCIntRectangle contentRect, string backgroundSprite)
            : base(backgroundRect, contentRect, ShowMode.Appear, HideMode.Disappear, 0, 0, backgroundSprite)
        {
            if (productIconSprites == null)
            {
                throw new ArgumentNullException("productIconSprites");
            }

            this.textFont        = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5");
            this.objectTypeTexts = new Dictionary <int, UIString>();

            this.isConnected                 = false;
            this.backgroundTask              = null;
            this.hpIndicatorSprites          = new Dictionary <MapObjectConditionEnum, SpriteGroup>();
            this.productIconSprites          = productIconSprites;
            this.currentCustomContent        = null;
            this.buttonArray                 = new RCSelectionButton[MAX_SELECTION_SIZE];
            this.productionLineDisplay       = null;
            this.constructionProgressDisplay = null;
            this.supplyDetailsDisplay        = null;
            this.resourceAmountDisplay       = null;
            this.weaponDetailsDisplay        = null;
            this.multiplayerService          = null;
            this.selectionDetailsView        = null;
            this.mapObjectDetailsView        = null;
            this.productionDetailsView       = null;
            this.selectionButtonsAdded       = false;
            this.hpTexts    = new Dictionary <MapObjectConditionEnum, UIString>();
            this.energyText = null;
        }
Exemple #5
0
        /// <summary>
        /// Sets a new list of items to be displayed in this listbox.
        /// </summary>
        /// <param name="itemStrings">The list of the items to be displayed.</param>
        public void SetItems(string[] itemStrings)
        {
            if (itemStrings == null)
            {
                throw new ArgumentNullException("itemStrings");
            }

            for (int i = 0; i < this.items.Length; i++)
            {
                this.items[i].Dispose();
                this.highlightedItems[i].Dispose();
                this.disabledItems[i].Dispose();
            }

            this.items            = new UIString[itemStrings.Length];
            this.highlightedItems = new UIString[itemStrings.Length];
            this.disabledItems    = new UIString[itemStrings.Length];
            this.itemStrings      = new string[itemStrings.Length];

            for (int i = 0; i < itemStrings.Length; i++)
            {
                this.items[i]            = new UIString(itemStrings[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.Green);
                this.highlightedItems[i] = new UIString(itemStrings[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.LightGreen);
                this.disabledItems[i]    = new UIString(itemStrings[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.White);
                this.itemStrings[i]      = itemStrings[i];
            }

            this.ItemCount = itemStrings.Length;
        }
Exemple #6
0
        /// <summary>
        /// Constructs an RCSelectGamePage instance.
        /// </summary>
        public RCSelectGamePage()
            : base()
        {
            this.background    = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.PlanetBackground");
            this.okButtonPanel = new RCNavButtonPanel(new RCIntRectangle(220, 139, 100, 32), new RCIntRectangle(0, 17, 81, 15),
                                                      UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToRight,
                                                      300, 300,
                                                      "RC.App.Sprites.OkBtnPanel",
                                                      "Ok");

            this.cancelButtonPanel = new RCNavButtonPanel(new RCIntRectangle(229, 155, 91, 35), new RCIntRectangle(0, 17, 82, 15),
                                                          UIPanel.ShowMode.DriftFromBottom, UIPanel.HideMode.DriftToBottom,
                                                          300, 300,
                                                          "RC.App.Sprites.CancelBtnPanel",
                                                          "Cancel");

            this.selectGamePanel = new RCSelectGamePanel(new RCIntRectangle(0, 0, 180, 159), new RCIntRectangle(23, 45, 157, 114),
                                                         UIPanel.ShowMode.DriftFromLeft, UIPanel.HideMode.DriftToLeft,
                                                         300, 300,
                                                         "RC.App.Sprites.LeftMediumPanel1");

            this.gameInfoPanel = new RCGameInfoPanel(new RCIntRectangle(193, 0, 127, 139), new RCIntRectangle(0, 20, 117, 119),
                                                     UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToRight,
                                                     300, 300,
                                                     "RC.App.Sprites.RightMediumPanel");

            this.RegisterPanel(this.okButtonPanel);
            this.RegisterPanel(this.cancelButtonPanel);
            this.RegisterPanel(this.selectGamePanel);
            this.RegisterPanel(this.gameInfoPanel);

            this.okButtonPanel.NavigationButton.Pressed     += this.OnButtonPressed;
            this.cancelButtonPanel.NavigationButton.Pressed += this.OnButtonPressed;
            this.selectGamePanel.CreateGameButton.Pressed   += this.OnButtonPressed;
        }
        /// <summary>
        /// Constructs a minimap display control at the given position with the given size.
        /// </summary>
        /// <param name="isoTileSpriteGroup">Reference to the sprites of the isometric tile types.</param>
        /// <param name="terrainObjectSpriteGroup">Reference to the sprites of the terrain object types.</param>
        /// <param name="position">The position of the minimap display control.</param>
        /// <param name="size">The size of the minimap display control.</param>
        public RCMinimapDisplay(ISpriteGroup isoTileSpriteGroup, ISpriteGroup terrainObjectSpriteGroup, RCIntVector position, RCIntVector size)
            : base(position, size)
        {
            if (isoTileSpriteGroup == null)
            {
                throw new ArgumentNullException("isoTileSpriteGroup");
            }
            if (terrainObjectSpriteGroup == null)
            {
                throw new ArgumentNullException("terrainObjectSpriteGroup");
            }

            this.minimapView                      = null;
            this.minimapScanner                   = null;
            this.scannerStatus                    = ScannerStatusEnum.Inactive;
            this.mouseHandler                     = null;
            this.showAttackSignalsFlag            = false;
            this.timeSinceAttackSignalFlagChanged = 0;
            this.spriteBuffer                     = null;
            this.isoTileSpriteGroup               = isoTileSpriteGroup;
            this.terrainObjectSpriteGroup         = terrainObjectSpriteGroup;

            this.connectionStatus        = ConnectionStatusEnum.Offline;
            this.backgroundTask          = null;
            this.stopBackgroundTaskEvent = null;
            this.newJobEvent             = null;
            this.jobQueue = new Fifo <IMinimapBackgroundJob>();

            this.crosshairsPointer   = UIResourceManager.GetResource <UIPointer>("RC.App.Pointers.CrosshairsPointer");
            this.windowLocationBrush = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.WhiteHigh, new RCIntVector(1, 1), UIWorkspace.Instance.PixelScaling);
            this.windowLocationBrush.Upload();
        }
Exemple #8
0
 /// <summary>
 /// Constructs an RCSelectionBoxDisplay extension for the given map display control.
 /// </summary>
 /// <param name="extendedControl">The map display control to extend.</param>
 public RCSelectionBoxDisplay(RCMapDisplay extendedControl)
     : base(extendedControl)
 {
     this.selectionBoxPointer = UIResourceManager.GetResource <UIPointer>("RC.App.Pointers.SelectionBoxPointer");
     this.crosshairsPointer   = UIResourceManager.GetResource <UIPointer>("RC.App.Pointers.CrosshairsPointer");
     this.selectionBoxBrush   = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.LightGreen, new RCIntVector(1, 1), UIWorkspace.Instance.PixelScaling);
     this.selectionBoxBrush.Upload();
 }
Exemple #9
0
 /// <summary>
 /// Constructs an RCMenuButton with the given text.
 /// </summary>
 public RCMenuButton(string text, RCIntRectangle buttonRect) : base(buttonRect.Location, buttonRect.Size)
 {
     this.menuButtonFont  = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B");
     this.normalText      = new UIString(text, this.menuButtonFont, UIWorkspace.Instance.PixelScaling, new RCColor(220, 220, 220));
     this.highlightedText = new UIString(text, this.menuButtonFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
     this.textPosition    = new RCIntVector((this.Range.Width - this.normalText.Width) / 2,
                                            (this.Range.Height - (this.menuButtonFont.CharBottomMaximum + this.menuButtonFont.CharTopMaximum + 1)) / 2 +
                                            this.menuButtonFont.CharTopMaximum);
 }
 /// <summary>
 /// Creates an RCSelectMapPanel instance.
 /// </summary>
 /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
 /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
 /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param>
 /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param>
 /// <param name="appearDuration">
 /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case
 /// of ShowMode.Appear.
 /// </param>
 /// <param name="disappearDuration">
 /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case
 /// of HideMode.Disappear.
 /// </param>
 /// <param name="backgroundSprite">
 /// Name of the sprite resource that will be the background of this panel or null if there is no background.
 /// </param>
 public RCSelectMapPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect,
                         ShowMode showMode, HideMode hideMode,
                         int appearDuration, int disappearDuration,
                         string backgroundSprite)
     : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite)
 {
     this.selectMapTitle = new UIString(SELECT_MAP_TITLE, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B"),
                                        UIWorkspace.Instance.PixelScaling, RCColor.LightBlue);
 }
 /// <summary>
 /// Constructs an RCIsoTileHighlightDisplay extension for the given map display control.
 /// </summary>
 /// <param name="extendedControl">The map display control to extend.</param>
 public RCIsoTileHighlightDisplay(RCMapDisplay extendedControl)
     : base(extendedControl)
 {
     this.mapTerrainView           = null;
     this.highlightIsoTile         = false;
     this.isotileHighlightedSprite = UIResourceManager.GetResource <UISprite>("RC.MapEditor.Sprites.IsotileHighlighted");
     this.isotileNormalSprite      = UIResourceManager.GetResource <UISprite>("RC.MapEditor.Sprites.IsotileNormal");
     this.lastKnownMousePosition   = RCIntVector.Undefined;
 }
Exemple #12
0
 /// <summary>
 /// Creates an RCAppPanel instance.
 /// </summary>
 /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
 /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
 /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param>
 /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param>
 /// <param name="appearDuration">
 /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case
 /// of ShowMode.Appear.
 /// </param>
 /// <param name="disappearDuration">
 /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case
 /// of HideMode.Disappear.
 /// </param>
 /// <param name="backgroundSprite">
 /// Name of the sprite resource that will be the background of this panel or null if there is no background.
 /// </param>
 /// <remarks>
 /// The backgroundRect shall entirely contain the contentRect.
 /// The origin of the panel's coordinate system will be the top-left corner of contentRect.
 /// The range rectangle of the panel will be backgroundRect relative to contentRect.
 /// The clip rectangle of the panel will be contentRect in the panel's coordinate system.
 /// </remarks>
 public RCAppPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect,
                   ShowMode showMode, HideMode hideMode,
                   int appearDuration, int disappearDuration,
                   string backgroundSprite)
     : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration)
 {
     this.StatusChanged += this.OnPanelStatusChanged;
     this.background     = backgroundSprite != null?UIResourceManager.GetResource <UISprite>(backgroundSprite) : null;
 }
 /// <summary>
 /// Constructs an RCResourceAmountTooltip extension for the given map display control.
 /// </summary>
 /// <param name="extendedControl">The map display control to extend.</param>
 public RCResourceAmountTooltip(RCMapDisplay extendedControl)
     : base(extendedControl)
 {
     this.mapObjectDetailsView = null;
     this.objectID             = -1;
     this.drawPosition         = RCIntVector.Undefined;
     this.stringToRender       = new UIString("R:{0}", UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.White);
     this.backgroundBrush      = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.Black, new RCIntVector(1, this.stringToRender.Font.MinimumLineHeight), UIWorkspace.Instance.PixelScaling);
     this.backgroundBrush.Upload();
 }
Exemple #14
0
 /// <summary>
 /// Creates an RCSelectGamePanel instance.
 /// </summary>
 /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
 /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
 /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param>
 /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param>
 /// <param name="appearDuration">
 /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case
 /// of ShowMode.Appear.
 /// </param>
 /// <param name="disappearDuration">
 /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case
 /// of HideMode.Disappear.
 /// </param>
 /// <param name="backgroundSprite">
 /// Name of the sprite resource that will be the background of this panel or null if there is no background.
 /// </param>
 public RCSelectGamePanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect,
                          ShowMode showMode, HideMode hideMode,
                          int appearDuration, int disappearDuration,
                          string backgroundSprite)
     : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite)
 {
     this.selectGameTitle = new UIString(SELECT_GAME_TITLE, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B"),
                                         UIWorkspace.Instance.PixelScaling, RCColor.LightBlue);
     this.createGameButton = new RCMenuButton(CREATE_GAME_BUTTON, new RCIntRectangle(0, 99, 85, 15));
     this.AddControl(this.createGameButton);
 }
Exemple #15
0
        static void Test6()
        {
            Assembly xnaPlugin = Assembly.Load("RC.UI.XnaPlugin, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null");

            new UIRoot();
            UIRoot.Instance.LoadPlugins(xnaPlugin);
            UIRoot.Instance.InstallPlugins();
            UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6").GetFontSprite(new RCIntVector(6, 3), new RCColor(255, 0, 0)).Save("c255_0_0_ps6_3.png");
            UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6").GetFontSprite(new RCIntVector(2, 3), new RCColor(0, 255, 0)).Save("c0_255_0_ps2_3.png");
            UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6").GetFontSprite(new RCIntVector(4, 4), new RCColor(0, 0, 255)).Save("c0_0_255_ps4_4.png");
        }
Exemple #16
0
 public MySensitiveAnimObject(RCIntVector position,
                              RCIntRectangle range,
                              string name,
                              RCColor basicColor,
                              RCColor highColor)
     : base(position, range, name, basicColor, highColor)
 {
     this.anim = UIResourceManager.GetResource <UIAnimation>("RC.App.Animations.MainMenuTitleAnim");
     this.anim.Reset(true);
     this.anim.Start();
 }
Exemple #17
0
 /// <summary>
 /// Creates an RCRegistryPanel instance.
 /// </summary>
 /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
 /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
 /// <param name="showMode">The mode how the panel will appear on a page when being shown.</param>
 /// <param name="hideMode">The mode how the panel will disappear from a page when being hidden.</param>
 /// <param name="appearDuration">
 /// The duration of showing this UIPanel in milliseconds. This parameter will be ignored in case
 /// of ShowMode.Appear.
 /// </param>
 /// <param name="disappearDuration">
 /// The duration of hiding this UIPanel in milliseconds. This parameter will be ignored in case
 /// of HideMode.Disappear.
 /// </param>
 /// <param name="backgroundSprite">
 /// Name of the sprite resource that will be the background of this panel or null if there is no background.
 /// </param>
 public RCRegistryPanel(RCIntRectangle backgroundRect, RCIntRectangle contentRect,
                        ShowMode showMode, HideMode hideMode,
                        int appearDuration, int disappearDuration,
                        string backgroundSprite)
     : base(backgroundRect, contentRect, showMode, hideMode, appearDuration, disappearDuration, backgroundSprite)
 {
     this.registryTitle = new UIString(REGISTRY_TITLE, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font9B"),
                                       UIWorkspace.Instance.PixelScaling, RCColor.LightBlue);
     this.newIdButton  = new RCMenuButton(NEW_ID_BUTTON, new RCIntRectangle(0, 99, 85, 15));
     this.deleteButton = new RCMenuButton(DELETE_BUTTON, new RCIntRectangle(88, 99, 66, 15));
     this.AddControl(this.newIdButton);
     this.AddControl(this.deleteButton);
 }
Exemple #18
0
 /// <summary>
 /// Constructs an RCMainMenuPage.
 /// </summary>
 public RCMainMenuPage()
 {
     this.currentPhase         = ShowPhase.OnlyBackground;
     this.firstActivationTime  = 0;
     this.hasBeenActivatedOnce = false;
     this.loadingTask          = null;
     this.background           = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.MainMenuBackground");
     this.titleAnimation       = UIResourceManager.GetResource <UIAnimation>("RC.App.Animations.MainMenuTitleAnim");
     this.headerFooterFont     = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6");
     this.loadingFont          = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font7");
     this.headerString         = new UIString("DAVID MOLDVAI ENTERTAINMENT PRESENTS:", this.headerFooterFont, UIWorkspace.Instance.PixelScaling, new RCColor(220, 220, 220));
     this.footerString         = new UIString("COPYRIGHT 1986", this.headerFooterFont, UIWorkspace.Instance.PixelScaling, new RCColor(220, 220, 220));
     this.loadingString        = new UIString("Loading...", this.loadingFont, UIWorkspace.Instance.PixelScaling, new RCColor(220, 220, 220));
 }
Exemple #19
0
        /// <summary>
        /// Constructs an RCListBox instance.
        /// </summary>
        /// <param name="position">The position of the RCListBox.</param>
        /// <param name="width">The width of the RCListBox.</param>
        /// <param name="visibleItemCount">
        /// The maximum number of items that can be visible in the listbox at a given time. If the number of
        /// items in the listbox is greater a vertical scrollbar is displayed along the right side of the control.
        /// </param>
        /// <param name="timeBetweenScrolls">
        /// The minimum time should be elapsed between scrolling the listbox in milliseconds.
        /// </param>
        public RCListBox(RCIntVector position, int width, int visibleItemCount, int timeBetweenScrolls)
            : base(position, new RCIntVector(width, HEIGHT), visibleItemCount, timeBetweenScrolls)
        {
            if (width <= TEXT_PADDING_LEFT + TEXT_PADDING_RIGHT)
            {
                throw new ArgumentOutOfRangeException("width", string.Format("Width must be at least {0}!", TEXT_PADDING_LEFT + TEXT_PADDING_RIGHT + 1));
            }

            this.items            = new UIString[0];
            this.highlightedItems = new UIString[0];
            this.disabledItems    = new UIString[0];
            this.itemStrings      = new string[0];
            this.textPartWidth    = width - TEXT_PADDING_LEFT - TEXT_PADDING_RIGHT;

            this.controlSprite = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ListBox");
        }
Exemple #20
0
        /// <summary>
        /// Constructs a resource bar.
        /// </summary>
        /// <param name="backgroundRect">The area of the background of the panel in workspace coordinates.</param>
        /// <param name="contentRect">The area of the content of the panel relative to the background rectangle.</param>
        /// <param name="backgroundSprite">Name of the sprite resource that will be the background of this panel or null if there is no background.</param>
        public RCResourceBar(RCIntRectangle backgroundRect, RCIntRectangle contentRect, string backgroundSprite)
            : base(backgroundRect, contentRect, ShowMode.Appear, HideMode.Disappear, 0, 0, backgroundSprite)
        {
            this.multiplayerService = ComponentManager.GetInterface <IMultiplayerService>();

            this.textFont               = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5");
            this.mineralsText           = new UIString("{0}", this.textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
            this.vespeneGasText         = new UIString("{0}", this.textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
            this.normalUsedSupplyText   = new UIString("{0}", this.textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
            this.criticalUsedSupplyText = new UIString("{0}", this.textFont, UIWorkspace.Instance.PixelScaling, RCColor.LightRed);
            this.totalSupplyText        = new UIString("/{0}", this.textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);

            this.playerView        = null;
            this.mineralsTracker   = null;
            this.vespeneGasTracker = null;
        }
Exemple #21
0
        public MyButton(RCIntVector position,
                        RCIntVector size,
                        RCColor basicColor,
                        RCColor highlightedColor,
                        RCColor disabledColor,
                        string text)
            : base(position, size)
        {
            this.textStr               = new UIString(text, UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font6"), new RCIntVector(2, 2), RCColor.Black);
            this.basicBackground       = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(basicColor, this.Range.Size - new RCIntVector(2, 2), new RCIntVector(2, 2));
            this.highlightedBackground = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(highlightedColor, this.Range.Size - new RCIntVector(2, 2), new RCIntVector(2, 2));
            this.disabledBackground    = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(disabledColor, this.Range.Size - new RCIntVector(2, 2), new RCIntVector(2, 2));

            this.basicBackground.Upload();
            this.highlightedBackground.Upload();
            this.disabledBackground.Upload();
        }
Exemple #22
0
        /// <summary>
        /// Constructs a construction progress display control at the given position with the given size.
        /// </summary>
        /// <param name="position">The position of the construction progress display control.</param>
        /// <param name="size">The size of the construction progress display control.</param>
        public RCConstructionProgressDisplay(RCIntVector position, RCIntVector size)
            : base(position, size)
        {
            IViewService viewService = ComponentManager.GetInterface <IViewService>();

            this.productionDetailsView = viewService.CreateView <IProductionDetailsView>();

            this.progressBarSprite = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ProductionProgressBar");
            this.progressBarBrush  = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.Green, new RCIntVector(1, 1), UIWorkspace.Instance.PixelScaling);
            this.progressBarBrush.Upload();

            UIFont textFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5");

            this.underConstructionText = new UIString("Under Construction", textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
            this.textPosition          = new RCIntVector(
                (PROGRESSBAR_INNER_RECT.Left + PROGRESSBAR_INNER_RECT.Right - this.underConstructionText.Width) / 2,
                PROGRESSBAR_SPRITE_POS.Y - this.underConstructionText.Font.CharBottomMaximum - 1);
        }
Exemple #23
0
 /// <summary>
 /// Creates a vertical or horizontal scrollbar with custom settings.
 /// </summary>
 /// <param name="position">The position of the upper-left corner of the scrollbar.</param>
 /// <param name="length">The length of the scrollbar.</param>
 /// <param name="settings">The settings of the scrollbar.</param>
 public RCScrollBar(RCIntVector position, int length, Settings settings)
     : base(position,
            settings.Alignment == Alignment.Horizontal ? new RCIntVector(length, RCScrollBar.WIDTH) : new RCIntVector(RCScrollBar.WIDTH, length),
            new UIScrollBar.Settings()
 {
     Alignment            = settings.Alignment == Alignment.Horizontal ? UIScrollBar.Alignment.Horizontal : UIScrollBar.Alignment.Vertical,
     ButtonExtension      = RCScrollBar.BUTTON_SIZE,
     IntervalLength       = settings.IntervalLength,
     SliderButtonRadius   = RCScrollBar.WIDTH / 2,
     StepValueChange      = settings.StepValueChange,
     TimeBetweenSteps     = settings.TimeBetweenSteps,
     TrackingValueChange  = settings.TrackingValueChange,
     TimeBetweenTrackings = settings.TimeBetweenTrackings
 })
 {
     this.controlSprite     = UIResourceManager.GetResource <UISprite>(settings.Alignment == Alignment.Horizontal ? "RC.App.Sprites.ScrollbarHorz" : "RC.App.Sprites.ScrollbarVert");
     this.alignment         = settings.Alignment;
     this.sliderTrackLength = length - 2 * RCScrollBar.BUTTON_SIZE;
 }
Exemple #24
0
        /// <summary>
        /// Constructs a RCResourceAmountDisplay control at the given position with the given size.
        /// </summary>
        /// <param name="position">The position of the control.</param>
        /// <param name="size">The size of the control.</param>
        public RCResourceAmountDisplay(RCIntVector position, RCIntVector size)
            : base(position, size)
        {
            IViewService viewService = ComponentManager.GetInterface <IViewService>();

            this.mapObjectDetailsView = viewService.CreateView <IMapObjectDetailsView>();
            this.selectionDetailsView = viewService.CreateView <ISelectionDetailsView>();

            UIFont textFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5");

            this.mineralsText = new List <UIString> {
                new UIString("Minerals: {0}", textFont, UIWorkspace.Instance.PixelScaling, RCColor.White)
            };
            this.vespeneGasText = new List <UIString> {
                new UIString("Vespene Gas: {0}", textFont, UIWorkspace.Instance.PixelScaling, RCColor.White)
            };
            this.depletedText = new List <UIString> {
                new UIString("Depleted", textFont, UIWorkspace.Instance.PixelScaling, RCColor.White)
            };
        }
Exemple #25
0
        public void EntityTypeNameTextWidthTest()
        {
            string entityTypeNamesPath = System.IO.Path.Combine(INPUT_DIR, ENTITY_TYPE_NAMES_FILE);

            string[] entityTypeNames      = File.ReadAllLines(entityTypeNamesPath);
            string[] entityTypeNameWidths = new string[entityTypeNames.Length];
            for (int i = 0; i < entityTypeNames.Length; i++)
            {
                UIString typeNameString = new UIString(entityTypeNames[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), new RCIntVector(1, 1), RCColor.White);

                //UISprite typeNameSprite = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.Black, new RCIntVector(typeNameString.Width, typeNameString.Font.MinimumLineHeight));
                //IUIRenderContext typeNameSpriteContext = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateRenderContext(typeNameSprite);
                //typeNameSpriteContext.RenderString(typeNameString);

                entityTypeNameWidths[i] = string.Format("{0} - Width: {1}, Height: {2}", entityTypeNames[i], typeNameString.Width, typeNameString.Font.MinimumLineHeight);
                typeNameString.Dispose();
            }
            string outputPath = System.IO.Path.Combine(OUTPUT_DIR, ENTITY_TYPE_NAME_WIDTHS_OUT_FILE);

            File.WriteAllLines(outputPath, entityTypeNameWidths);
        }
        /// <summary>
        /// Constructs an RCSelectGamePage instance.
        /// </summary>
        public RCMultiSetupPage()
            : base()
        {
            this.background    = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.PlanetBackground");
            this.okButtonPanel = new RCNavButtonPanel(new RCIntRectangle(220, 139, 100, 32), new RCIntRectangle(0, 17, 81, 15),
                                                      UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToRight,
                                                      300, 300,
                                                      "RC.App.Sprites.OkBtnPanel",
                                                      "Ok");

            this.cancelButtonPanel = new RCNavButtonPanel(new RCIntRectangle(229, 155, 91, 35), new RCIntRectangle(0, 17, 82, 15),
                                                          UIPanel.ShowMode.DriftFromBottom, UIPanel.HideMode.DriftToBottom,
                                                          300, 300,
                                                          "RC.App.Sprites.CancelBtnPanel",
                                                          "Cancel");

            this.multiSetupPanel = new RCMultiSetupPanel(new RCIntRectangle(0, 0, 180, 139), new RCIntRectangle(10, 11, 170, 128),
                                                         UIPanel.ShowMode.DriftFromLeft, UIPanel.HideMode.DriftToLeft,
                                                         300, 300,
                                                         "RC.App.Sprites.LeftLargePanel");

            this.multiChatPanel = new RCMultiChatPanel(new RCIntRectangle(0, 131, 180, 67), new RCIntRectangle(6, 11, 174, 56),
                                                       UIPanel.ShowMode.DriftFromBottom, UIPanel.HideMode.DriftToBottom,
                                                       300, 300,
                                                       "RC.App.Sprites.MultiChatPanel");

            this.gameInfoPanel = new RCGameInfoPanel(new RCIntRectangle(193, 0, 127, 139), new RCIntRectangle(0, 20, 117, 119),
                                                     UIPanel.ShowMode.DriftFromRight, UIPanel.HideMode.DriftToRight,
                                                     300, 300,
                                                     "RC.App.Sprites.RightMediumPanel");

            this.RegisterPanel(this.okButtonPanel);
            this.RegisterPanel(this.cancelButtonPanel);
            this.RegisterPanel(this.multiSetupPanel);
            this.RegisterPanel(this.multiChatPanel);
            this.RegisterPanel(this.gameInfoPanel);

            this.okButtonPanel.NavigationButton.Pressed     += this.OnButtonPressed;
            this.cancelButtonPanel.NavigationButton.Pressed += this.OnButtonPressed;
        }
Exemple #27
0
        /// <summary>
        /// Constructs a RCWeaponDetailsDisplay control at the given position with the given size.
        /// </summary>
        /// <param name="position">The position of the control.</param>
        /// <param name="size">The size of the control.</param>
        public RCWeaponDetailsDisplay(RCIntVector position, RCIntVector size)
            : base(position, size)
        {
            IViewService viewService = ComponentManager.GetInterface <IViewService>();

            this.mapObjectDetailsView = viewService.CreateView <IMapObjectDetailsView>();
            this.selectionDetailsView = viewService.CreateView <ISelectionDetailsView>();
            this.metadataView         = viewService.CreateView <IMetadataView>();

            UIFont textFont = UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5");

            this.displayedTexts = new List <UIString>();

            /// Load the UIStrings for displaying the weapon names.
            this.weaponTexts = new Dictionary <string, UIString>();
            foreach (KeyValuePair <string, string> weaponName in this.metadataView.GetWeaponDisplayedNames())
            {
                this.weaponTexts.Add(weaponName.Key,
                                     new UIString(string.Format("{0}: {{0}}", weaponName.Value), textFont, UIWorkspace.Instance.PixelScaling, RCColor.White));
            }
            this.armorText = new UIString("Armor: {0}", textFont, UIWorkspace.Instance.PixelScaling, RCColor.White);
        }
        /// <summary>
        /// Constructs a dropdown selector control.
        /// </summary>
        /// <param name="position">The position of the control.</param>
        /// <param name="width">The width of the control in pixels.</param>
        /// <param name="options">The list of the options available in the control.</param>
        public RCDropdownSelector(RCIntVector position, int width, string[] options)
            : base(position, new RCIntVector(width, HEIGHT), options.Length)
        {
            if (width <= TEXT_PADDING + ARROW_WIDTH)
            {
                throw new ArgumentOutOfRangeException("width", string.Format("Width must be at least {0}!", TEXT_PADDING + ARROW_WIDTH + 1));
            }

            this.options            = new UIString[options.Length];
            this.highlightedOptions = new UIString[options.Length];
            this.disabledOptions    = new UIString[options.Length];
            this.textPartWidth      = width - TEXT_PADDING - ARROW_WIDTH;

            for (int i = 0; i < options.Length; i++)
            {
                this.options[i]            = new UIString(options[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.Green);
                this.highlightedOptions[i] = new UIString(options[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.LightGreen);
                this.disabledOptions[i]    = new UIString(options[i], UIResourceManager.GetResource <UIFont>("RC.App.Fonts.Font5"), UIWorkspace.Instance.PixelScaling, RCColor.White);
            }

            this.controlSprite = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.DropdownSelector");
        }
        /// <summary>
        /// Constructs a production line display control at the given position with the given size.
        /// </summary>
        /// <param name="productIconSprites">The product icon sprite group.</param>
        /// <param name="position">The position of the production line display control.</param>
        /// <param name="size">The size of the production line display control.</param>
        public RCProductionLineDisplay(ISpriteGroup productIconSprites, RCIntVector position, RCIntVector size)
            : base(position, size)
        {
            if (productIconSprites == null)
            {
                throw new ArgumentNullException("productIconSprites");
            }

            IViewService viewService = ComponentManager.GetInterface <IViewService>();

            this.productionDetailsView = viewService.CreateView <IProductionDetailsView>();

            this.progressBarSprite = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ProductionProgressBar");
            this.progressBarBrush  = UIRoot.Instance.GraphicsPlatform.SpriteManager.CreateSprite(RCColor.Green, new RCIntVector(1, 1), UIWorkspace.Instance.PixelScaling);
            this.progressBarBrush.Upload();

            for (int buttonIndex = 0; buttonIndex < PRODUCTION_BUTTON_COUNT; buttonIndex++)
            {
                RCProductionButton prodButton = new RCProductionButton(productIconSprites, buttonIndex);
                this.Attach(prodButton);
                this.AttachSensitive(prodButton);
            }
        }
        /// <summary>
        /// Constructs a production button at the given layout index inside the production display.
        /// </summary>
        /// <param name="productIconSprites">The product icon sprite group.</param>
        /// <param name="layoutIndex">The index in the layout of this button on the production display.</param>
        public RCProductionButton(ISpriteGroup productIconSprites, int layoutIndex)
            : base(BUTTON_POSITIONS[layoutIndex].Location, BUTTON_POSITIONS[layoutIndex].Size)
        {
            if (layoutIndex < 0)
            {
                throw new ArgumentOutOfRangeException("layoutIndex", "Production button layout index must be non-negative!");
            }
            if (productIconSprites == null)
            {
                throw new ArgumentNullException("productIconSprites");
            }

            IViewService viewService = ComponentManager.GetInterface <IViewService>();

            this.productionDetailsView = viewService.CreateView <IProductionDetailsView>();
            this.commandService        = ComponentManager.GetInterface <ICommandService>();

            this.productionButtonSprite = UIResourceManager.GetResource <UISprite>("RC.App.Sprites.ProductionButton");
            this.layoutIndex            = layoutIndex;
            this.productIconSprites     = productIconSprites;

            this.Pressed += this.OnButtonPressed;
        }