public static void Init(IFontFactory fontLoader) { const string path = "Fonts/Font Awesome 5 Free-Solid-900.otf"; Font = fontLoader.LoadFontFromPath(path, 14f, FontStyle.Regular); IconConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.NoFitting, alignment: Alignment.MiddleCenter, paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f); ButtonConfig = fontLoader.GetTextConfig(font: Font, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter, paddingLeft: 0f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f); var tinyFont = fontLoader.LoadFontFromPath(path, 8f, FontStyle.Regular); TinyButtonConfig = fontLoader.GetTextConfig(font: tinyFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter, paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f); TinyButtonConfigHovered = AGSTextConfig.ChangeColor(TinyButtonConfig, Colors.Black, Colors.White, 0f); var largeFont = fontLoader.LoadFontFromPath(path, 56f, FontStyle.Regular); LargeIconConfig = fontLoader.GetTextConfig(font: largeFont, autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter, paddingLeft: -1f, paddingTop: 0f, paddingBottom: 0f, paddingRight: 0f, outlineWidth: 1f); LargeIconConfigHovered = AGSTextConfig.ChangeColor(LargeIconConfig, GameViewColors.HoveredText, Colors.White, 0f); }
public async Task <ICharacter> LoadAsync(IGame game) { AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0)); var footstep = await game.Factory.Sound.LoadAudioClipAsync("Sounds/151238__owlstorm__hard-female-footstep-2.wav"); ISoundEmitter emitter = new AGSSoundEmitter(game); emitter.AudioClip = footstep; IOutfit outfit = await game.Factory.Outfit.LoadOutfitFromFoldersAsync(_baseFolder, walkLeftFolder : "Walk/left", walkDownFolder : "Walk/front", idleLeftFolder : "Idle/left", idleDownFolder : "Idle/front", speakLeftFolder : "Talk", loadConfig : loadConfig); _character = game.Factory.Object.GetCharacter("Cris", outfit).Remember(game, c => _character = c); _character.SpeechConfig.TextConfig = AGSTextConfig.ChangeColor(_character.SpeechConfig.TextConfig, Colors.OrangeRed, Colors.Black, 1f); var approach = _character.AddComponent <IApproachComponent>(); approach.ApproachStyle.ApproachWhenVerb["Talk"] = ApproachHotspots.WalkIfHaveWalkPoint; emitter.Object = _character; _character.AddComponent <ISaturationEffectComponent>(); var movement = _character.AddComponent <KeyboardMovement>(); movement.AddArrows(); movement.AddWASD(); //Uncomment for portrait /* * var portrait = game.Factory.Object.GetObject("CrisPortrait"); * portrait.StartAnimation(game.Factory.Graphics.LoadAnimationFromFolder(_baseFolder + "Talk")); * portrait.Border = game.Factory.Graphics.Borders.SolidColor(Colors.AliceBlue, 3f, true); * portrait.Visible = false; * portrait.RenderLayer = AGSLayers.Speech; * portrait.IgnoreViewport = true; * portrait.IgnoreScalingArea = true; * game.State.UI.Add(portrait); * _character.SpeechConfig.PortraitConfig = new AGSPortraitConfig { Portrait = portrait, Positioning = PortraitPositioning.Alternating }; */ var speakAnimation = _character.Outfit[AGSOutfit.Speak]; Characters.RandomAnimationDelay(speakAnimation.Left); Characters.RandomAnimationDelay(speakAnimation.Right); emitter.Assign(_character.Outfit[AGSOutfit.Walk], 1, 5); _character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down); _character.DisplayName = "Cris"; _character.IsPixelPerfect = true; Characters.Cris = _character; return(_character); }
public async Task <ICharacter> LoadAsync(IGame game) { _game = game; IGameFactory factory = game.Factory; AGSLoadImageConfig loadConfig = new AGSLoadImageConfig(new Point(0, 0)); IOutfit outfit = await factory.Outfit.LoadOutfitFromFoldersAsync(_baseFolder, walkLeftFolder : "Walk/left", walkDownFolder : "Walk/down", walkRightFolder : "Walk/right", walkUpFolder : "Walk/up", idleLeftFolder : "Idle/left", idleDownFolder : "Idle/down", idleRightFolder : "Idle/right", idleUpFolder : "Idle/up", speakLeftFolder : "Talk/left", speakDownFolder : "Talk/down", speakRightFolder : "Talk/right", speakUpFolder : "Talk/up", loadConfig : loadConfig); _character = factory.Object.GetCharacter("Beman", outfit).Remember(_game, character => { _character = character; subscribeEvents(); }); _character.SpeechConfig.TextConfig = AGSTextConfig.ChangeColor(_character.SpeechConfig.TextConfig, Colors.CornflowerBlue, Colors.Black, 1f); _character.SpeechConfig.TextOffset = (0f, -10f); //Uncomment for portrait /* * var portrait = game.Factory.Object.GetObject("BemanPortrait"); * portrait.StartAnimation(game.Factory.Graphics.LoadAnimationFromFolder(_baseFolder + "Talk/down")); * portrait.Border = game.Factory.Graphics.Borders.SolidColor(Colors.AliceBlue, 3f, true); * portrait.Visible = false; * portrait.RenderLayer = AGSLayers.Speech; * portrait.IgnoreViewport = true; * portrait.IgnoreScalingArea = true; * game.State.UI.Add(portrait); * _character.SpeechConfig.PortraitConfig = new AGSPortraitConfig { Portrait = portrait, Positioning = PortraitPositioning.Alternating }; */ var speakAnimation = _character.Outfit[AGSOutfit.Speak]; Characters.RandomAnimationDelay(speakAnimation.Left); Characters.RandomAnimationDelay(speakAnimation.Right); Characters.RandomAnimationDelay(speakAnimation.Down); Characters.RandomAnimationDelay(speakAnimation.Up); _character.StartAnimation(_character.Outfit[AGSOutfit.Idle].Down); _character.DisplayName = "Beman"; _character.IsPixelPerfect = true; Characters.Beman = _character; _dialogs.Load(game); return(_character); }
public void Init(IGameFactory factory, AGSEditor editor) { _pointer = factory.UI.GetLabel("PointerCursor", "", 25f, 25f, 0f, 0f, config: FontIcons.IconConfig, addToUi: false); _pointer.Text = FontIcons.Pointer; _pointer.Pivot = new PointF(0.29f, 0.83f); var toolbarHeight = _resolution.Height / 20f; _toolbar = factory.UI.GetPanel("GameToolbar", _resolution.Width / 2f, toolbarHeight, _resolution.Width / 2f, _resolution.Height - toolbarHeight); _toolbar.Pivot = new PointF(0.5f, 0f); _toolbar.Tint = GameViewColors.SubPanel; _toolbar.RenderLayer = new AGSRenderLayer(-99999, independentResolution: _resolution); _toolbar.ClickThrough = false; _toolbar.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, 3f, true); var idle = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.Button); var hover = new ButtonAnimation(null, AGSTextConfig.ChangeColor(FontIcons.ButtonConfig, Colors.Yellow, Colors.White, 0f), GameViewColors.HoveredButton); var pushed = new ButtonAnimation(null, FontIcons.ButtonConfig, GameViewColors.PushedButton); const float buttonWidth = 50f; float buttonHeight = _toolbar.Height * 3 / 4f; float buttonY = _toolbar.Height / 2f; float buttonX = _toolbar.Width / 2f; _playPauseButton = factory.UI.GetButton("PlayPauseGameButton", idle, hover, pushed, buttonX, buttonY, _toolbar, width: buttonWidth, height: buttonHeight); _playPauseButton.Text = FontIcons.Pause; _playPauseButton.Pivot = new PointF(0.5f, 0.5f); _playPauseButton.RenderLayer = _toolbar.RenderLayer; _playPauseButton.MouseClicked.Subscribe(onPlayPauseClicked); _fpsLabel = factory.UI.GetLabel("FPS Label (Editor)", "", 30f, 25f, 0f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font)); _fpsLabel.Pivot = new PointF(0f, 0.5f); _fpsLabel.TextBackgroundVisible = false; _fpsLabel.RenderLayer = _toolbar.RenderLayer; _fpsLabel.Enabled = true; _fpsLabel.MouseEnter.Subscribe(_ => _fpsLabel.Tint = Colors.Indigo); _fpsLabel.MouseLeave.Subscribe(_ => _fpsLabel.Tint = Colors.IndianRed.WithAlpha(125)); _mousePosLabel = factory.UI.GetLabel("Mouse Position Label (Editor)", "", 1f, 1f, 120f, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(autoFit: AutoFit.LabelShouldFitText, font: _font)); _mousePosLabel.TextBackgroundVisible = false; _mousePosLabel.Pivot = new PointF(0f, 0.5f); _mousePosLabel.RenderLayer = _toolbar.RenderLayer; _hotspotLabel = factory.UI.GetLabel("Debug Hotspot Label (Editor)", "", 250f, _fpsLabel.Height, _toolbar.Width, _playPauseButton.Y, _toolbar, config: factory.Fonts.GetTextConfig(alignment: Alignment.TopRight, autoFit: AutoFit.TextShouldFitLabel, font: _font)); _hotspotLabel.TextBackgroundVisible = false; _hotspotLabel.Pivot = new PointF(1f, 0.5f); _hotspotLabel.RenderLayer = _toolbar.RenderLayer; }
public RotateHandle(ILabel handle, AGSEditor editor, IGameState state, IInput input, ActionManager actions, Direction direction) { _editor = editor; _actions = actions; _state = state; _idleConfig = handle.TextConfig; _hoverConfig = AGSTextConfig.ChangeColor(handle.TextConfig, Colors.Yellow, Colors.White, 0f); _direction = direction; _input = input; _handle = handle; setIcon(); _handle.Visible = false; _handle.Enabled = true; _handle.RenderLayer = AGSLayers.UI; _handle.TextBackgroundVisible = false; _handle.MouseEnter.Subscribe(onMouseEnter); _handle.MouseDown.Subscribe(onMouseDown); _handle.MouseLeave.Subscribe(onMouseLeave); state.UI.Add(_handle); }
public void Load() { const float headerHeight = 50f; const float borderWidth = 3f; IGameFactory factory = _editor.Editor.Factory; _panel = factory.UI.GetPanel(_panelId, _layer.IndependentResolution.Value.Width / 4f, _layer.IndependentResolution.Value.Height, 1f, _layer.IndependentResolution.Value.Height / 2f); _panel.Pivot = new PointF(0f, 0.5f); _panel.Visible = false; _panel.Tint = GameViewColors.Panel; _panel.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true); _panel.RenderLayer = _layer; _panel.ClickThrough = false; _editor.Editor.State.FocusedUI.CannotLoseFocus.Add(_panelId); var headerLabel = factory.UI.GetLabel("GameDebugTreeLabel", "Game Debug", _panel.Width, headerHeight, 0f, _panel.Height - headerHeight, _panel, new AGSTextConfig(alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel)); headerLabel.Tint = Colors.Transparent; headerLabel.Border = factory.Graphics.Borders.SolidColor(GameViewColors.Border, borderWidth, hasRoundCorners: true); headerLabel.RenderLayer = _layer; var xButton = factory.UI.GetButton("GameDebugTreeCloseButton", (IAnimation)null, null, null, 0f, _panel.Height - headerHeight + 5f, _panel, "X", new AGSTextConfig(factory.Graphics.Brushes.LoadSolidBrush(Colors.Red), autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter), width: 40f, height: 40f); xButton.Pivot = new PointF(); xButton.RenderLayer = _layer; xButton.Tint = Colors.Transparent; xButton.MouseEnter.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f)); xButton.MouseLeave.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Red, Colors.Transparent, 0f)); xButton.MouseClicked.Subscribe(_ => Hide()); _panesButton = factory.UI.GetButton("GameDebugViewPanesButton", (IAnimation)null, null, null, _panel.Width, xButton.Y, _panel, "Display List", new AGSTextConfig(autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleRight), width: 120f, height: 40f); _panesButton.Pivot = new PointF(1f, 0f); _panesButton.RenderLayer = _layer; _panesButton.Tint = GameViewColors.Button; _panesButton.MouseEnter.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.HoveredText, GameViewColors.HoveredText, 0.3f)); _panesButton.MouseLeave.Subscribe(_ => _panesButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, GameViewColors.Text, Colors.Transparent, 0f)); _panesButton.MouseClicked.SubscribeToAsync(onPaneSwitch); var parentPanelHeight = _panel.Height - headerHeight; var parentPanel = factory.UI.GetPanel("GameDebugParentPanel", _panel.Width, parentPanelHeight, 0f, parentPanelHeight, _panel); parentPanel.Pivot = new PointF(0f, 1f); parentPanel.Tint = Colors.Transparent; parentPanel.RenderLayer = _layer; var topPanel = factory.UI.GetPanel("GameDebugTopPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel); topPanel.Pivot = new PointF(0f, 0f); topPanel.Tint = Colors.Transparent; topPanel.RenderLayer = _layer; var bottomPanel = factory.UI.GetPanel("GameDebugBottomPanel", _panel.Width, parentPanelHeight / 2f, 0f, parentPanelHeight / 2f, parentPanel); bottomPanel.Pivot = new PointF(0f, 1f); bottomPanel.Tint = Colors.Transparent; bottomPanel.RenderLayer = _layer; Tree.Load(topPanel); _displayList.Load(topPanel); _inspector.Load(bottomPanel); _currentTab = Tree; _splitPanel = parentPanel.AddComponent <ISplitPanelComponent>(); _splitPanel.TopPanel = topPanel; _splitPanel.BottomPanel = bottomPanel; var horizSplit = _panel.AddComponent <ISplitPanelComponent>(); horizSplit.IsHorizontal = true; horizSplit.TopPanel = _panel; _panel.GetComponent <IScaleComponent>().PropertyChanged += (_, args) => { if (args.PropertyName != nameof(IScaleComponent.Width)) { return; } _panesButton.X = _panel.Width; headerLabel.LabelRenderSize = new SizeF(_panel.Width, headerLabel.LabelRenderSize.Height); parentPanel.BaseSize = new SizeF(_panel.Width, parentPanel.Height); topPanel.BaseSize = new SizeF(_panel.Width, topPanel.Height); bottomPanel.BaseSize = new SizeF(_panel.Width, bottomPanel.Height); _currentTab.Resize(); _inspector.Resize(); resizeGameWindow(); }; }
public void Load(IGame game) { const float headerHeight = 50f; const float borderWidth = 3f; _game = game; IGameFactory factory = game.Factory; _panel = factory.UI.GetPanel(_panelId, 800, 600, _layer.IndependentResolution.Value.Width / 2f, _layer.IndependentResolution.Value.Height / 2f); _panel.Pivot = new PointF(0.5f, 0.5f); _panel.Visible = false; _panel.Tint = Colors.Black; _panel.Border = AGSBorders.SolidColor(Colors.Green, borderWidth, hasRoundCorners: true); _panel.RenderLayer = _layer; _panel.AddComponent <IModalWindowComponent>(); var headerLabel = factory.UI.GetLabel("FeaturesHeaderLabel", "Guided Tour", _panel.Width, headerHeight, 0f, _panel.Height - headerHeight, _panel, new AGSTextConfig(alignment: Alignment.MiddleCenter, autoFit: AutoFit.TextShouldFitLabel)); headerLabel.Tint = Colors.Transparent; headerLabel.Border = _panel.Border; headerLabel.RenderLayer = _layer; var xButton = factory.UI.GetButton("FeaturesCloseButton", (IAnimation)null, null, null, 0f, _panel.Height - headerHeight + 5f, _panel, "X", new AGSTextConfig(factory.Graphics.Brushes.LoadSolidBrush(Colors.Red), autoFit: AutoFit.TextShouldFitLabel, alignment: Alignment.MiddleCenter), width: 40f, height: 40f); xButton.Pivot = new PointF(); xButton.RenderLayer = _layer; xButton.Tint = Colors.Transparent; xButton.MouseEnter.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Yellow, Colors.White, 0.3f)); xButton.MouseLeave.Subscribe(_ => xButton.TextConfig = AGSTextConfig.ChangeColor(xButton.TextConfig, Colors.Red, Colors.Transparent, 0f)); xButton.OnMouseClick(hide, _game); var leftSidePanel = factory.UI.GetPanel("FeaturesLeftSidePanel", _panel.Width / 4f, _panel.Height - headerHeight - borderWidth, 0f, 0f, _panel); leftSidePanel.Tint = Colors.Transparent; leftSidePanel.RenderLayer = _layer; leftSidePanel.Border = _panel.Border; _rightSidePanel = factory.UI.GetPanel("FeaturesRightSidePanel", _panel.Width - leftSidePanel.Width, leftSidePanel.Height, leftSidePanel.Width, 0f, _panel); _rightSidePanel.RenderLayer = _layer; _rightSidePanel.Tint = Colors.Green.WithAlpha(50); var treePanel = factory.UI.GetPanel("FeaturesTreePanel", 1f, 1f, 0f, _panel.Height - headerHeight - 40f, leftSidePanel); treePanel.Tint = Colors.Transparent; treePanel.RenderLayer = _layer; var tree = createFeaturesLabel("Features", null); var treeView = treePanel.AddComponent <ITreeViewComponent>(); var roomsLabel = createFeaturesLabel("Rooms", tree); createFeaturesLabel("Viewports", roomsLabel, () => new FeaturesViewportsPanel(_game, _rightSidePanel)); createFeaturesLabel("Moving Areas", roomsLabel, () => new FeaturesMoveAreaPanel(_game, _rightSidePanel, _scheme)); var uiLabel = createFeaturesLabel("GUIs", tree); createFeaturesLabel("Labels", uiLabel, () => new FeaturesLabelsPanel(_game, _rightSidePanel)); var objLabel = createFeaturesLabel("Objects", tree); createFeaturesLabel("Textures", objLabel, () => new FeaturesTexturesPanel(_game, _rightSidePanel)); createFeaturesLabel("Tweens", objLabel, () => new FeaturesTweenPanel(_game, _rightSidePanel, _panel)); treeView.Tree = tree; treeView.OnNodeSelected.Subscribe(onTreeNodeSelected); _game.Events.OnSavedGameLoad.Subscribe(findPanel); }