Esempio n. 1
0
        /// <summary>
        /// This constructor will be used by ghost construction implementations to pass in the building data for the building we are building
        /// </summary>
        /// <param name="data"></param>
        public GhostConstruction(Data data)
            : base(Constants.GUI_DEPTH - 1)
        {
            if (data == null)
            {
                Logger.Log(LogLevel.Error, "GhostConstruction", string.Format("Null Data object passed into ghost construction. Probably an invalid cast in the catalog data."));
                return;
            }

            this.basedata = data;

            this.Size = new Pair<int>(this.basedata.Image.Width, this.basedata.Image.Height);
            this.Type = ElementType.Building;
            this.Clickable = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Create a build button. All this information should be stored in a configuration file for easy testing.
        /// The specs is a comma separated list of specs. Up to 4 can be displayed... any more and we will have to do a quick redesign.
        /// </summary>
        /// <param name="data">The data this side-button is based on</param>
        /// <param name="parent">The parent scroll bar</param>
        /// <param name="depth">Depth of the button</param>
        public SideFolderButton(Data data, Pair<int> size, ScrollBar parent, int depth)
            : base(size, parent, depth)
        {
            this.parent = parent;
            this.data = data;

            var specsStringList = new List<string>();

            BuildingData buildingData = data as BuildingData;
            if (buildingData != null)
            {
                foreach (var pair in buildingData.Specs)
                {
                    string key = pair.Key.ToString();
                    int value = pair.Value;
                    specsStringList.Add(string.Format("{0} {1}{2}", key, (value < 0 ? "" : "+"), value));
                }
            }

            this.specsString = specsStringList;
            this.dirtyImageBit = true;
        }