Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StoreItemManager"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public StoreItemManager(BlackbirdGame game)
 {
     this.game            = game;
     this.storeItems      = new Dictionary <string, StoreItem>();
     this.researchItems   = new Dictionary <string, StoreItem>();
     this.productionItems = new Dictionary <string, StoreItem>();
 }
Пример #2
0
        /// <summary>
        /// Parses the specified input string.
        /// </summary>
        /// <param name="game">The game instance.</param>
        /// <param name="inputString">The input string.</param>
        /// <param name="sender">The <see cref="GuiControl" /> instance to use as sender in a <see cref="GuiScriptedValue`1" />.</param>
        /// <returns></returns>
        public static GuiValue <T> Parse(BlackbirdGame game, string inputString, GuiControl sender)
        {
            if (inputString == null || inputString == "$null")
            {
                return(new GuiNullValue <T>(game));
            }

            // Scripted values.
            if (inputString.StartsWith("$=") || inputString.StartsWith("${"))
            {
                return(new GuiScriptedValue <T>(game, inputString.Substring(1), sender));
            }
            else if (inputString.StartsWith("#=") || inputString.StartsWith("#{"))
            {
                return(new GuiScriptedValue <T>(game, inputString, sender));
            }

            if (inputString.StartsWith("$"))
            {
                return(new GuiVariableValue <T>(game, inputString.Substring(1)));
            }
            else
            {
                return(new GuiConstantValue <T>(game, XmlHelper.Parse <T>(inputString)));
            }
        }
Пример #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiBackground"/> class.
        /// </summary>
        public GuiSize(BlackbirdGame game)
        {
            this.Game = game;

            Width  = new GuiNullValue <int>(Game);
            Height = new GuiNullValue <int>(Game);
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiBackground"/> class.
        /// </summary>
        public GuiBackground(BlackbirdGame game)
        {
            this.Game = game;

            Color  = new GuiNullValue <Color>(Game);
            Image  = new GuiNullValue <string>(Game);
            Repeat = new GuiNullValue <GuiRepeatStyle>(Game);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="StationModuleMiningStore"/> class.
        /// </summary>
        public MiningStoreStationModule(BlackbirdGame game)
            : base(game)
        {
            this.StoreItems     = new Dictionary <string, int>();
            this.StoreMaterials = new Dictionary <string, int>();

            LoadItemTemplates();
        }
Пример #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiFace"/> class.
        /// </summary>
        /// <param name="id">The id.</param>
        public GuiFace(BlackbirdGame game, string id)
        {
            this.Game = game;

            this.Id         = id;
            this.Background = new GuiBackground(game);
            this.Size       = new GuiSize(game);
            this.Controls   = new List <GuiControl>();
        }
Пример #7
0
    public Core(BlackbirdGame game)
        : base(game, "Core")
    {
        Events.KeyboardUp  += Events_KeyboardUp;
        Events.MouseMotion += Events_MouseMotion;

        game.GameLoaded += new EventHandler(game_GameLoaded);
        game.Time        = 3100000;
        game.VariableManager.SetVariable("time", game.FormattedTime);
    }
Пример #8
0
        /// <summary>
        /// Loads the specified control.
        /// </summary>
        /// <param name="game">The game.</param>
        /// <param name="element">The element.</param>
        /// <returns></returns>
        public static GuiControl Load(BlackbirdGame game, XmlElement element, string currentFileName)
        {
            string type = element.GetAttributeOrNull("type");

            if (type == null)
            {
                throw new BlackbirdException(string.Format(Resources.ModFileIsInIncorrectFormatSpecificException, currentFileName, "null", "type"));
            }

            GuiControl control = XmlHelper.CreateType(game, type, game) as GuiControl;

            control.Load(element, currentFileName);
            return(control);
        }
Пример #9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GuiScriptedValue&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="game">The game.</param>
        public GuiScriptedValue(BlackbirdGame game, string code, GuiControl sender)
            : base(game)
        {
            int idx = Interlocked.Increment(ref GuiScriptedValueUniqueIndex.uniqueIndex);
            // "global::" should make sure the type is right even when there are some name clashes (for example usings with an alias the same as a namespace etc.)
            string typeName = "global::" + typeof(T).FullName;

            this.methodName = "__" + GuiScriptedValueUniqueIndex.uniqueIndex.ToString("X4");
            this.sender     = sender;
            string senderId = "EmptySenderId";

            if (sender != null && sender.Id.HasValue)
            {
                senderId = sender.Id.Value;
            }

            // NOTE: The generated code should perhaps be marked by the CompilerGenerated attribute?

            // Code only specifies the return value.
            if (code.StartsWith("="))
            {
                game.ScriptManager.RegisterInlineMethod(string.Format("\r\n#line 1 \"gc:{3}\" \r\nprivate {0} {1}(global::Teraluwide.Blackbird.Core.Gui.Controls.GuiControl sender) {{ return {2}; }}", typeName, methodName, code.Substring(1), senderId), this);
            }
            // Code is the whole method body including the return statement.
            else if (code.StartsWith("{"))
            {
                game.ScriptManager.RegisterInlineMethod(string.Format("\r\n#line 1 \"gc:{3}\" \r\nprivate {0} {1}(global::Teraluwide.Blackbird.Core.Gui.Controls.GuiControl sender) {2}", typeName, methodName, code, senderId), this);
            }
            // Code is data bound.
            else if (code.StartsWith("#{"))
            {
                dataBound = true;
                game.ScriptManager.RegisterInlineMethod(string.Format("\r\n#line 1 \"gc:{3}\" \r\nprivate {0} {1}(global::Teraluwide.Blackbird.Core.Gui.Controls.GuiControl sender, Teraluwide.Blackbird.Core.ScriptingSupport.IDataContainer container) {2}", typeName, methodName, code.Substring(1), senderId), this);
            }
            // Code is a data bound return value.
            else if (code.StartsWith("#="))
            {
                dataBound = true;
                game.ScriptManager.RegisterInlineMethod(string.Format("\r\n#line 1 \"gc:{3}\" \r\nprivate {0} {1}(global::Teraluwide.Blackbird.Core.Gui.Controls.GuiControl sender, Teraluwide.Blackbird.Core.ScriptingSupport.IDataContainer container) {{ return {2}; }}", typeName, methodName, code.Substring(2), senderId), this);
            }
        }
Пример #10
0
        public static GuiEventReference <T> Parse(BlackbirdGame game, string inputString, GuiControl sender)
        {
            // A null event reference. Is not method bound so it will not be called.
            if (inputString == null || inputString == "$null")
            {
                return(new GuiEventReference <T>(game, sender));
            }

            // Inline event (lambda-like syntax).
            if (inputString.StartsWith("("))
            {
                GuiEventReference <T> reference = new GuiEventReference <T>(game, sender);
                reference.methodName = "__L" + GuiEventReferenceUniqueIndex.GetNewIndex().ToString("X4");
                string code     = inputString;
                string typeName = "global::" + typeof(GuiControlEventDelegate <>).Namespace + ".GuiControlEventDelegate<global::" + typeof(T).FullName + ">";
                string senderId = "EmptySenderId";
                if (sender != null && sender.Id.HasValue)
                {
                    senderId = sender.Id.Value;
                }

                reference.IsInline = true;

                game.ScriptManager.RegisterInlineMethod(string.Format("\r\n#line 1 \"gc:{3}\" \r\nprivate {0} {1}(global::Teraluwide.Blackbird.Core.Gui.Controls.GuiControl sender) {{ return {2}; }}", typeName, reference.methodName, code, senderId), reference);

                return(reference);
            }
            // Late-bound to a script method.
            else
            {
                GuiEventReference <T> reference = new GuiEventReference <T>(game, sender);
                reference.methodName = inputString;
                reference.IsInline   = false;
                game.ScriptManager.RegisterLateBinder(reference);

                return(reference);
            }
        }
Пример #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiNullValue&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiNullValue(BlackbirdGame game)
     : base(game)
 {
 }
Пример #12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiConstantValue`1"/> class.
 /// </summary>
 /// <param name="value">The value.</param>
 public GuiConstantValue(BlackbirdGame game, T value)
     : base(game)
 {
     this.value = value;
 }
Пример #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiEventReference&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiEventReference(BlackbirdGame game, GuiControl sender)
 {
     this.Game   = game;
     this.sender = sender;
 }
Пример #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationModuleBase"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public StationModuleBase(BlackbirdGame game)
 {
     this.Game = game;
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiVariableValue`1"/> class.
 /// </summary>
 /// <param name="variableName">Name of the variable.</param>
 public GuiVariableValue(BlackbirdGame game, string variableName)
     : base(game)
 {
     this.variableName = variableName;
 }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiLabel"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiLabel(BlackbirdGame game)
     : base(game)
 {
 }
Пример #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationManager"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public UniverseManager(BlackbirdGame game)
 {
     this.game     = game;
     this.galaxies = new Dictionary <string, Galaxy>();
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationComponent"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public StationComponent(BlackbirdGame game)
 {
     this.Game = game;
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameVariableManager"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GameVariableManager(BlackbirdGame game)
 {
     this.game      = game;
     this.variables = new Dictionary <string, IGameVariable>();
 }
Пример #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiValue`1"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiValue(BlackbirdGame game)
 {
     this.Game = game;
 }
Пример #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiLabel"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiFaceControl(BlackbirdGame game)
     : base(game)
 {
 }
Пример #22
0
 /// <summary>
 /// Parses the specified input string.
 /// </summary>
 /// <param name="game">The game instance.</param>
 /// <param name="inputString">The input string.</param>
 /// <returns></returns>
 public static GuiValue <T> Parse(BlackbirdGame game, string inputString)
 {
     return(Parse(game, inputString, null));
 }
Пример #23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GameVariableManager"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public ScriptManager(BlackbirdGame game)
 {
     this.game          = game;
     this.inlineMethods = new StringBuilder();
     this.methodBinders = new List <ILateMethodBinder>();
 }
Пример #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiBackground"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 /// <param name="el">The el.</param>
 /// <param name="currentFileName">Name of the current file.</param>
 public GuiSize(BlackbirdGame game, XmlElement el, string currentFileName)
     : this(game)
 {
     Load(el, currentFileName);
 }
Пример #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiControl"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiControl(BlackbirdGame game)
 {
     this.Game = game;
 }
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiManager"/> class.
 /// </summary>
 /// <param name="game">The game instance.</param>
 public GuiManager(BlackbirdGame game)
 {
     this.game = game;
     innerData = new Dictionary <string, GuiFace>();
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationBase"/> class.
 /// </summary>
 public StationBase(BlackbirdGame game)
 {
     this.Game = game;
     modules   = new List <StationModuleBase>();
 }
Пример #28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="StationManager"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public StationManager(BlackbirdGame game)
 {
     this.game     = game;
     this.stations = new Dictionary <string, StationBase>();
 }
Пример #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GuiRepeaterControl"/> class.
 /// </summary>
 /// <param name="game">The game.</param>
 public GuiRepeaterControl(BlackbirdGame game)
     : base(game)
 {
 }
Пример #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Station"/> class.
 /// </summary>
 /// <param name="game"></param>
 public Station(BlackbirdGame game)
     : base(game)
 {
 }