/// <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>(); }
/// <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))); } }
/// <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); }
/// <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(); }
/// <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>(); }
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); }
/// <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); }
/// <summary> /// Initializes a new instance of the <see cref="GuiScriptedValue<T>"/> 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); } }
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); } }
/// <summary> /// Initializes a new instance of the <see cref="GuiNullValue<T>"/> class. /// </summary> /// <param name="game">The game.</param> public GuiNullValue(BlackbirdGame game) : base(game) { }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="GuiEventReference<T>"/> class. /// </summary> /// <param name="game">The game.</param> public GuiEventReference(BlackbirdGame game, GuiControl sender) { this.Game = game; this.sender = sender; }
/// <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; }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="GuiLabel"/> class. /// </summary> /// <param name="game">The game.</param> public GuiLabel(BlackbirdGame game) : base(game) { }
/// <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>(); }
/// <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; }
/// <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>(); }
/// <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; }
/// <summary> /// Initializes a new instance of the <see cref="GuiLabel"/> class. /// </summary> /// <param name="game">The game.</param> public GuiFaceControl(BlackbirdGame game) : base(game) { }
/// <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)); }
/// <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>(); }
/// <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); }
/// <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; }
/// <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>(); }
/// <summary> /// Initializes a new instance of the <see cref="StationBase"/> class. /// </summary> public StationBase(BlackbirdGame game) { this.Game = game; modules = new List <StationModuleBase>(); }
/// <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>(); }
/// <summary> /// Initializes a new instance of the <see cref="GuiRepeaterControl"/> class. /// </summary> /// <param name="game">The game.</param> public GuiRepeaterControl(BlackbirdGame game) : base(game) { }
/// <summary> /// Initializes a new instance of the <see cref="Station"/> class. /// </summary> /// <param name="game"></param> public Station(BlackbirdGame game) : base(game) { }