/// <summary> /// Screen インスタンスのプロパティを設定します。 /// </summary> /// <param name="definition">ScreenDefinition。</param> /// <param name="screen">Screen インスタンス。</param> protected virtual void PopulateProperties(ScreenDefinition definition, Screen screen) { // デフォルトの SpriteFont を設定します。 // Screen.Font プロパティは、ScreenDefinition のプロパティ定義や、 // Screen.Initialize() 内で、独自の SpriteFont へオーバライドされる可能性があります。 screen.Font = Font; // デフォルトの ILookAndFeelSource を設定します。 screen.LookAndFeelSource = LookAndFeelSource; foreach (var property in definition.Properties) { var propertyInfo = screen.GetType().GetProperty(property.Key); if (propertyInfo == null) { throw new InvalidOperationException( string.Format("Property '{0}' could not be found in '{1}'.", property.Key, screen.GetType())); } propertyInfo.SetValue(screen, property.Value, null); } // Screen が IScreenFactoryAware ならば自分を通知します。 var screenFactoryAware = screen as IScreenFactoryAware; if (screenFactoryAware != null) { screenFactoryAware.ScreenFactory = this; } }
/// <summary> /// Screen インスタンスのプロパティを設定します。 /// </summary> /// <param name="definition">ScreenDefinition。</param> /// <param name="screen">Screen インスタンス。</param> protected virtual void PopulateProperties(ScreenDefinition definition, Screen screen) { // デフォルトの SpriteFont を設定します。 // Screen.Font プロパティは、ScreenDefinition のプロパティ定義や、 // Screen.Initialize() 内で、独自の SpriteFont へオーバライドされる可能性があります。 screen.Font = Font; // デフォルトの ILookAndFeelSource を設定します。 screen.LookAndFeelSource = LookAndFeelSource; foreach (var property in definition.Properties) { var propertyInfo = screen.GetType().GetProperty(property.Key); if (propertyInfo == null) throw new InvalidOperationException( string.Format("Property '{0}' could not be found in '{1}'.", property.Key, screen.GetType())); propertyInfo.SetValue(screen, property.Value, null); } // Screen が IScreenFactoryAware ならば自分を通知します。 var screenFactoryAware = screen as IScreenFactoryAware; if (screenFactoryAware != null) screenFactoryAware.ScreenFactory = this; }
/// <summary> /// Screen インスタンスを初期化します。 /// 既定の実装では Screen.Initialize() メソッドを呼び出します。 /// </summary> /// <remarks> /// このメソッドは、PopulateProperties メソッド呼び出しの後に呼び出されます。 /// </remarks> /// <param name="definition"></param> /// <param name="screen"></param> protected virtual void InitializeScreenInstance(ScreenDefinition definition, Screen screen) { screen.Initialize(); }
/// <summary> /// Screen をインスタンス化します。 /// </summary> /// <param name="definition">ScreenDefinition。</param> /// <returns>Screen インスタンス。</returns> protected virtual Screen CreateScreenInstance(ScreenDefinition definition) { return Activator.CreateInstance(definition.Type, Game) as Screen; }
/// <summary> /// Screen インスタンスを初期化します。 /// 既定の実装では Screen.Initialize() メソッドを呼び出します。 /// </summary> /// <remarks> /// このメソッドは、PopulateProperties メソッド呼び出しの後に呼び出されます。 /// </remarks> /// <param name="definition"></param> /// <param name="screen"></param> protected virtual void InitializeScreenInstance(ScreenDefinition definition, Screen screen) { screen.Initialize(); }
/// <summary> /// Screen をインスタンス化します。 /// </summary> /// <param name="definition">ScreenDefinition。</param> /// <returns>Screen インスタンス。</returns> protected virtual Screen CreateScreenInstance(ScreenDefinition definition) { return(Activator.CreateInstance(definition.Type, Game) as Screen); }