Ejemplo n.º 1
0
        public TextRenderable(SpriteFont font, WPos pos, int zOffset, Color color, string text)
            : this(font, pos, zOffset, color,
			       ChromeMetrics.Get<Color>("TextContrastColorDark"),
			       ChromeMetrics.Get<Color>("TextContrastColorLight"),
			       text)
        {
        }
        public ProductionPaletteWidget([ObjectCreator.Param] World world,
		                               [ObjectCreator.Param] WorldRenderer worldRenderer)
        {
            this.world = world;
            this.worldRenderer = worldRenderer;
            tooltipContainer = new Lazy<TooltipContainerWidget>(() =>
                Widget.RootWidget.GetWidget<TooltipContainerWidget>(TooltipContainer));

            cantBuild = new Animation("clock");
            cantBuild.PlayFetchIndex("idle", () => 0);
            clock = new Animation("clock");

            iconSprites = Rules.Info.Values
                .Where(u => u.Traits.Contains<BuildableInfo>() && u.Name[0] != '^')
                .ToDictionary(
                    u => u.Name,
                    u => Game.modData.SpriteLoader.LoadAllSprites(
                        u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]);

            overlayFont = Game.Renderer.Fonts["TinyBold"];
            holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2;
            readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2;
            timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4,2);
        }
Ejemplo n.º 3
0
 public FloatingText(WPos pos, Color color, string text, int duration)
 {
     this.font = Game.Renderer.Fonts["TinyBold"];
     this.pos = pos;
     this.color = color;
     this.text = text;
     this.remaining = duration;
 }
Ejemplo n.º 4
0
 public TextRenderable(SpriteFont font, WPos pos, int zOffset, Color color, string text)
 {
     this.font = font;
     this.pos = pos;
     this.zOffset = zOffset;
     this.color = color;
     this.text = text;
 }
Ejemplo n.º 5
0
		public RenderNameTag(Actor self, RenderNameTagInfo info)
		{
			font = Game.Renderer.Fonts[info.Font];
			color = self.Owner.Color.RGB;

			if (self.Owner.PlayerName.Length > info.MaxLength)
				name = self.Owner.PlayerName.Substring(0, info.MaxLength);
			else
				name = self.Owner.PlayerName;
		}
Ejemplo n.º 6
0
 public CashTick(string value, int lifetime, int velocity, float2 pos, Color color)
 {
     this.color = color;
     this.velocity = velocity;
     this.pos = pos;
     s = value;
     font = Game.Renderer.Fonts["TinyBold"];
     offset = 0.5f*font.Measure(s).ToFloat2();
     remaining = lifetime;
 }
Ejemplo n.º 7
0
        public MapPreviewWidget()
        {
            tooltipContainer = Exts.Lazy(() => Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            spawnClaimed = ChromeProvider.GetImage("lobby-bits", "spawn-claimed");
            spawnUnclaimed = ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed");
            spawnFont = Game.Renderer.Fonts[ChromeMetrics.Get<string>("SpawnFont")];
            spawnColor = ChromeMetrics.Get<Color>("SpawnColor");
            spawnContrastColor = ChromeMetrics.Get<Color>("SpawnContrastColor");
            spawnLabelOffset = ChromeMetrics.Get<int2>("SpawnLabelOffset");
        }
Ejemplo n.º 8
0
        public MissionBrowserLogic(Widget widget, Action onStart, Action onExit)
        {
            this.onStart = onStart;

            var missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");
            var template = widget.Get<ScrollItemWidget>("MISSION_TEMPLATE");

            widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null;

            var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
            previewWidget.Preview = () => selectedMapPreview;

            descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");
            description = widget.Get<LabelWidget>("MISSION_DESCRIPTION");
            descriptionFont = Game.Renderer.Fonts[description.Font];

            var yaml = new MiniYaml(null, Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal)).NodesDict;

            var missionMapPaths = yaml["Missions"].Nodes.Select(n => Path.GetFullPath(n.Key));

            var maps = Game.modData.MapCache
                .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
                .Select(p => p.Map);

            missionList.RemoveChildren();
            foreach (var m in maps)
            {
                var map = m;

                var item = ScrollItemWidget.Setup(template,
                    () => selectedMapPreview != null && selectedMapPreview.Uid == map.Uid,
                    () => SelectMap(map),
                    StartMission);

                item.Get<LabelWidget>("TITLE").GetText = () => map.Title;
                missionList.AddChild(item);
            }

            if (maps.Any())
                SelectMap(maps.First());

            widget.Get<ButtonWidget>("STARTGAME_BUTTON").OnClick = StartMission;

            widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                Game.Disconnect();
                Ui.CloseWindow();
                onExit();
            };
        }
Ejemplo n.º 9
0
        public RenderDebugState(Actor self, RenderDebugStateInfo info)
        {
            var buildingInfo = self.Info.TraitInfoOrDefault<BuildingInfo>();
            var yOffset = buildingInfo == null ? 1 : buildingInfo.Dimensions.Y;
            offset = new WVec(0, 512 * yOffset, 0);

            this.self = self;
            color = GetColor();
            font = Game.Renderer.Fonts[info.Font];

            var localPlayer = self.World.LocalPlayer;
            devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
            ai = self.Owner.PlayerActor.TraitsImplementing<HackyAI>().FirstOrDefault(x => x.IsEnabled);
        }
Ejemplo n.º 10
0
        public void Init()
        {
            // Avoid standard loading mechanisms so we
            // can display loadscreen as early as possible
            r = Game.Renderer;
            if (r == null) return;
            Font = r.BoldFont;

            var s = new Sheet("mods/ra/loadscreen.png");
            Logo = new Sprite(s, new Rectangle(0,0,256,256), TextureChannel.Alpha);
            Stripe = new Sprite(s, new Rectangle(256,0,256,256), TextureChannel.Alpha);
            StripeRect = new Rectangle(0, Renderer.Resolution.Height/2 - 128, Renderer.Resolution.Width, 256);
            LogoPos =  new float2(Renderer.Resolution.Width/2 - 128, Renderer.Resolution.Height/2 - 128);
        }
Ejemplo n.º 11
0
        public override void Display()
        {
            if (r == null || loadTimer.Elapsed.TotalSeconds < 0.25)
                return;

            loadTimer.Restart();

            loadTick = ++loadTick % 8;
            r.BeginFrame(int2.Zero, 1f);
            r.RgbaSpriteRenderer.DrawSprite(gdiLogo, gdiPos);
            r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
            r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);

            WidgetUtils.DrawPanelPartial(bounds, PanelSides.Edges,
                borderTop, borderBottom, borderLeft, borderRight,
                cornerTopLeft, cornerTopRight, cornerBottomLeft, cornerBottomRight,
                null);
            var barY = bounds.Height - 78;

            if (!setup && r.Fonts != null)
            {
                loadingFont = r.Fonts["BigBold"];
                loadingText = loadInfo["Text"];
                loadingPos = new float2((bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);

                versionFont = r.Fonts["Regular"];
                var versionSize = versionFont.Measure(versionText);
                versionPos = new float2(bounds.Width - 107 - versionSize.X / 2, 115 - versionSize.Y / 2);

                setup = true;
            }

            if (loadingFont != null)
                loadingFont.DrawText(loadingText, loadingPos, Color.Gray);
            if (versionFont != null)
                versionFont.DrawTextWithContrast(versionText, versionPos, Color.White, Color.Black, 2);

            for (var i = 0; i <= 8; i++)
            {
                var block = loadTick == i ? brightBlock : dimBlock;
                r.RgbaSpriteRenderer.DrawSprite(block,
                    new float2(bounds.Width / 2 - 114 - i * 32, barY));
                r.RgbaSpriteRenderer.DrawSprite(block,
                    new float2(bounds.Width / 2 + 114 + i * 32 - 16, barY));
            }

            r.EndFrame(nih);
        }
Ejemplo n.º 12
0
        public void Display()
        {
            if (r == null || loadTimer.ElapsedTime() < 0.25)
                return;

            loadTimer.Reset();

            loadTick = ++loadTick % 8;
            r.BeginFrame(float2.Zero, 1f);
            r.RgbaSpriteRenderer.DrawSprite(gdiLogo, gdiPos);
            r.RgbaSpriteRenderer.DrawSprite(nodLogo, nodPos);
            r.RgbaSpriteRenderer.DrawSprite(evaLogo, evaPos);

            WidgetUtils.DrawPanelPartial(ss, Bounds, PanelSides.Edges);
            var barY = Bounds.Height - 78;

            if (!setup && r.Fonts != null)
            {
                loadingFont = r.Fonts["BigBold"];
                loadingText = "Loading";
                loadingPos = new float2((Bounds.Width - loadingFont.Measure(loadingText).X) / 2, barY);

                versionFont = r.Fonts["Regular"];
                versionText = WidgetUtils.ActiveModVersion();
                var versionSize = versionFont.Measure(versionText);
                versionPos = new float2(Bounds.Width - 107 - versionSize.X/2, 115 - versionSize.Y/2);

                setup = true;
            }

            if (loadingFont != null)
                loadingFont.DrawText(loadingText, loadingPos, Color.Gray);
            if (versionFont != null)
                versionFont.DrawTextWithContrast(versionText, versionPos, Color.White, Color.Black, 2);

            for (var i = 0; i <= 8; i++)
            {
                var block = loadTick == i ? brightBlock : dimBlock;
                r.RgbaSpriteRenderer.DrawSprite(block,
                    new float2(Bounds.Width / 2 - 114 - i * 32, barY));
                r.RgbaSpriteRenderer.DrawSprite(block,
                    new float2(Bounds.Width / 2 + 114 + i * 32 - 16, barY));
            }

            r.EndFrame(nih);
        }
Ejemplo n.º 13
0
        protected MapPreviewWidget(MapPreviewWidget other)
            : base(other)
        {
            Preview = other.Preview;

            IgnoreMouseInput = other.IgnoreMouseInput;
            ShowSpawnPoints = other.ShowSpawnPoints;
            TooltipTemplate = other.TooltipTemplate;
            TooltipContainer = other.TooltipContainer;
            SpawnOccupants = other.SpawnOccupants;

            tooltipContainer = Exts.Lazy(() => Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            spawnClaimed = ChromeProvider.GetImage("lobby-bits", "spawn-claimed");
            spawnUnclaimed = ChromeProvider.GetImage("lobby-bits", "spawn-unclaimed");
            spawnFont = Game.Renderer.Fonts[ChromeMetrics.Get<string>("SpawnFont")];
            spawnColor = ChromeMetrics.Get<Color>("SpawnColor");
            spawnContrastColor = ChromeMetrics.Get<Color>("SpawnContrastColor");
            spawnLabelOffset = ChromeMetrics.Get<int2>("SpawnLabelOffset");
        }
        public SupportPowersWidget(World world, WorldRenderer worldRenderer)
        {
            this.worldRenderer = worldRenderer;
            spm = world.LocalPlayer.PlayerActor.Trait<SupportPowerManager>();
            tooltipContainer = Lazy.New(() =>
                Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));

            iconSprites = Rules.Info.Values.SelectMany( u => u.Traits.WithInterface<SupportPowerInfo>() )
                .Select(u => u.Image).Distinct()
                .ToDictionary(
                    u => u,
                    u => Game.modData.SpriteLoader.LoadAllSprites(u)[0]);

            clock = new Animation("clock");

            overlayFont = Game.Renderer.Fonts["TinyBold"];
            holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2;
            readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2;
            timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
        }
Ejemplo n.º 15
0
        public override void Draw()
        {
            overlayFont = Game.Renderer.Fonts["TinyBold"];
            holdOffset = new float2(32, 24) - overlayFont.Measure(HoldText) / 2;
            readyOffset = new float2(32, 24) - overlayFont.Measure(ReadyText) / 2;
            timeOffset = new float2(32, 24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;

            // Background
            foreach (var rect in icons.Keys)
                WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));

            // Icons
            foreach (var p in icons.Values)
            {
                WidgetUtils.DrawSHP(p.Sprite, p.Pos, worldRenderer);

                // Charge progress
                clock.PlayFetchIndex("idle",
                    () => (p.Power.TotalTime - p.Power.RemainingTime)
                        * (clock.CurrentSequence.Length - 1) / p.Power.TotalTime);
                clock.Tick();
                WidgetUtils.DrawSHP(clock.Image, p.Pos, worldRenderer);
            }

            // Overlay
            foreach (var p in icons.Values)
            {
                if (p.Power.Ready)
                    overlayFont.DrawTextWithContrast(ReadyText,
                        p.Pos + readyOffset,
                        Color.White, Color.Black, 1);
                else if (!p.Power.Active)
                    overlayFont.DrawTextWithContrast(HoldText,
                        p.Pos + holdOffset,
                        Color.White, Color.Black, 1);
                else
                    overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime),
                        p.Pos + timeOffset,
                        Color.White, Color.Black, 1);
            }
        }
Ejemplo n.º 16
0
        public MissionBrowserLogic(Widget widget, Action onStart, Action onExit)
        {
            this.onStart = onStart;

            missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");

            headerTemplate = widget.Get<ScrollItemWidget>("HEADER");
            template = widget.Get<ScrollItemWidget>("TEMPLATE");

            var title = widget.GetOrNull<LabelWidget>("MISSIONBROWSER_TITLE");
            if (title != null)
                title.GetText = () => showVideoPlayer ? selectedMapPreview.Title : title.Text;

            widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null;

            var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
            previewWidget.Preview = () => selectedMapPreview;
            previewWidget.IsVisible = () => !showVideoPlayer;

            videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO");
            widget.Get("MISSION_BIN").IsVisible = () => showVideoPlayer;

            descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");

            description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION");
            descriptionFont = Game.Renderer.Fonts[description.Font];

            startVideoButton = widget.Get<ButtonWidget>("START_VIDEO_BUTTON");
            stopVideoButton = widget.Get<ButtonWidget>("STOP_VIDEO_BUTTON");
            stopVideoButton.IsVisible = () => showVideoPlayer;
            stopVideoButton.OnClick = StopVideo;

            var allMaps = new List<Map>();
            missionList.RemoveChildren();

            // Add a group for each campaign
            if (Game.modData.Manifest.Missions.Any())
            {
                var yaml = Game.modData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);

                foreach (var kv in yaml)
                {
                    var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key));

                    var maps = Game.modData.MapCache
                        .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
                        .Select(p => p.Map);

                    CreateMissionGroup(kv.Key, maps);
                    allMaps.AddRange(maps);
                }
            }

            // Add an additional group for loose missions
            // Loose missions must define Type: Mission and Selectable: false.
            var looseMissions = Game.modData.MapCache
                .Where(p => p.Status == MapStatus.Available && p.Map.Type == "Mission" && !p.Map.Selectable && !allMaps.Contains(p.Map))
                .Select(p => p.Map);

            if (looseMissions.Any())
            {
                CreateMissionGroup("Missions", looseMissions);
                allMaps.AddRange(looseMissions);
            }

            if (allMaps.Any())
                SelectMap(allMaps.First());

            var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
            startButton.OnClick = StartMission;
            startButton.IsDisabled = () => selectedMapPreview.RuleStatus != MapRuleStatus.Cached;

            widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                StopVideo();
                Game.Disconnect();
                Ui.CloseWindow();
                onExit();
            };
        }
Ejemplo n.º 17
0
		public override void Draw()
		{
			var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
			overlayFont = Game.Renderer.Fonts["TinyBold"];

			holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
			readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;
			timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, worldRenderer.World.Timestep)) / 2;

			// Icons
			foreach (var p in icons.Values)
			{
				WidgetUtils.DrawSHPCentered(p.Sprite, p.Pos + iconOffset, p.Palette);

				// Charge progress
				var sp = p.Power;
				clock.PlayFetchIndex(ClockSequence,
					() => sp.TotalTime == 0 ? clock.CurrentSequence.Length - 1 : (sp.TotalTime - sp.RemainingTime)
					* (clock.CurrentSequence.Length - 1) / sp.TotalTime);

				clock.Tick();
				WidgetUtils.DrawSHPCentered(clock.Image, p.Pos + iconOffset, p.IconClockPalette);
			}

			// Overlay
			foreach (var p in icons.Values)
			{
				if (p.Power.Ready)
					overlayFont.DrawTextWithContrast(ReadyText,
						p.Pos + readyOffset,
						Color.White, Color.Black, 1);
				else if (!p.Power.Active)
					overlayFont.DrawTextWithContrast(HoldText,
						p.Pos + holdOffset,
						Color.White, Color.Black, 1);
				else
					overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(p.Power.RemainingTime, worldRenderer.World.Timestep),
						p.Pos + timeOffset,
						Color.White, Color.Black, 1);
			}
		}
Ejemplo n.º 18
0
		public override void Draw()
		{
			var iconSize = new float2(64, 48);
			var iconOffset = 0.5f * iconSize;

			overlayFont = Game.Renderer.Fonts["TinyBold"];
			timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
			queuedOffset = new float2(4, 2);
			holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
			readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;

			if (CurrentQueue == null)
				return;

			var buildableItems = CurrentQueue.BuildableItems();

			// Background
			foreach (var rect in icons.Keys)
				WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1, 1, 1, 1));

			// Icons
			foreach (var icon in icons.Values)
			{
				WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, worldRenderer);

				// Build progress
				if (icon.Queued.Count > 0)
				{
					var first = icon.Queued[0];
					clock.PlayFetchIndex("idle",
						() => (first.TotalTime - first.RemainingTime)
							* (clock.CurrentSequence.Length - 1) / first.TotalTime);
					clock.Tick();
					WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, worldRenderer);
				}
				else if (!buildableItems.Any(a => a.Name == icon.Name))
					WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, worldRenderer);
			}

			// Overlays
			foreach (var icon in icons.Values)
			{
				var total = icon.Queued.Count;
				if (total > 0)
				{
					var first = icon.Queued[0];
					var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
					if (first.Done)
					{
						if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0)
							overlayFont.DrawTextWithContrast(ReadyText,
							                                 icon.Pos + readyOffset,
							                                 Color.White, Color.Black, 1);
						else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
								overlayFont.DrawTextWithContrast(ReadyText,
								                                 icon.Pos + readyOffset,
								                                 ReadyTextAltColor, Color.Black, 1);
					}
					else if (first.Paused)
						overlayFont.DrawTextWithContrast(HoldText,
														 icon.Pos + holdOffset,
														 Color.White, Color.Black, 1);
					else if (!waiting)
						overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual),
														 icon.Pos + timeOffset,
														 Color.White, Color.Black, 1);

					if (total > 1 || waiting)
						overlayFont.DrawTextWithContrast(total.ToString(),
														 icon.Pos + queuedOffset,
														 Color.White, Color.Black, 1);
				}
			}
		}
Ejemplo n.º 19
0
		public MissionBrowserLogic(Widget widget, World world, Action onStart, Action onExit)
		{
			this.onStart = onStart;

			missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");

			headerTemplate = widget.Get<ScrollItemWidget>("HEADER");
			template = widget.Get<ScrollItemWidget>("TEMPLATE");

			var title = widget.GetOrNull<LabelWidget>("MISSIONBROWSER_TITLE");
			if (title != null)
				title.GetText = () => playingVideo != PlayingVideo.None ? selectedMapPreview.Title : title.Text;

			widget.Get("MISSION_INFO").IsVisible = () => selectedMapPreview != null;

			var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
			previewWidget.Preview = () => selectedMapPreview;
			previewWidget.IsVisible = () => playingVideo == PlayingVideo.None;

			videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO");
			widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None;
			fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } });

			descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");

			description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION");
			descriptionFont = Game.Renderer.Fonts[description.Font];

			difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
			gameSpeedButton = widget.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON");

			startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON");
			stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON");
			stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing;
			stopBriefingVideoButton.OnClick = () => StopVideo(videoPlayer);

			startInfoVideoButton = widget.Get<ButtonWidget>("START_INFO_VIDEO_BUTTON");
			stopInfoVideoButton = widget.Get<ButtonWidget>("STOP_INFO_VIDEO_BUTTON");
			stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info;
			stopInfoVideoButton.OnClick = () => StopVideo(videoPlayer);

			var allMaps = new List<Map>();
			missionList.RemoveChildren();

			// Add a group for each campaign
			if (Game.ModData.Manifest.Missions.Any())
			{
				var yaml = Game.ModData.Manifest.Missions.Select(MiniYaml.FromFile).Aggregate(MiniYaml.MergeLiberal);

				foreach (var kv in yaml)
				{
					var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key));

					var maps = Game.ModData.MapCache
						.Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(Path.GetFullPath(p.Map.Path)))
						.Select(p => p.Map);

					CreateMissionGroup(kv.Key, maps);
					allMaps.AddRange(maps);
				}
			}

			// Add an additional group for loose missions
			var looseMissions = Game.ModData.MapCache
				.Where(p => p.Status == MapStatus.Available && p.Map.Visibility.HasFlag(MapVisibility.MissionSelector) && !allMaps.Contains(p.Map))
				.Select(p => p.Map);

			if (looseMissions.Any())
			{
				CreateMissionGroup("Missions", looseMissions);
				allMaps.AddRange(looseMissions);
			}

			if (allMaps.Any())
				SelectMap(allMaps.First());

			var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
			startButton.OnClick = StartMissionClicked;
			startButton.IsDisabled = () => selectedMapPreview == null || selectedMapPreview.RuleStatus != MapRuleStatus.Cached;

			widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
			{
				StopVideo(videoPlayer);
				Game.Disconnect();
				Ui.CloseWindow();
				onExit();
			};
		}
Ejemplo n.º 20
0
 public CustomTerrainDebugOverlay(Actor self, CustomTerrainDebugOverlayInfo info)
 {
     font = Game.Renderer.Fonts[info.Font];
 }
Ejemplo n.º 21
0
        public MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit)
        {
            this.modData = modData;
            this.onStart = onStart;
            Game.BeforeGameStart += OnGameStart;

            missionList = widget.Get<ScrollPanelWidget>("MISSION_LIST");

            headerTemplate = widget.Get<ScrollItemWidget>("HEADER");
            template = widget.Get<ScrollItemWidget>("TEMPLATE");

            var title = widget.GetOrNull<LabelWidget>("MISSIONBROWSER_TITLE");
            if (title != null)
                title.GetText = () => playingVideo != PlayingVideo.None ? selectedMap.Title : title.Text;

            widget.Get("MISSION_INFO").IsVisible = () => selectedMap != null;

            var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
            previewWidget.Preview = () => selectedMap;
            previewWidget.IsVisible = () => playingVideo == PlayingVideo.None;

            videoPlayer = widget.Get<VqaPlayerWidget>("MISSION_VIDEO");
            widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None;
            fullscreenVideoPlayer = Ui.LoadWidget<BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs { { "world", world } });

            descriptionPanel = widget.Get<ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");

            description = descriptionPanel.Get<LabelWidget>("MISSION_DESCRIPTION");
            descriptionFont = Game.Renderer.Fonts[description.Font];

            difficultyButton = widget.Get<DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
            gameSpeedButton = widget.GetOrNull<DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON");

            startBriefingVideoButton = widget.Get<ButtonWidget>("START_BRIEFING_VIDEO_BUTTON");
            stopBriefingVideoButton = widget.Get<ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON");
            stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing;
            stopBriefingVideoButton.OnClick = () => StopVideo(videoPlayer);

            startInfoVideoButton = widget.Get<ButtonWidget>("START_INFO_VIDEO_BUTTON");
            stopInfoVideoButton = widget.Get<ButtonWidget>("STOP_INFO_VIDEO_BUTTON");
            stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info;
            stopInfoVideoButton.OnClick = () => StopVideo(videoPlayer);

            var allPreviews = new List<MapPreview>();
            missionList.RemoveChildren();

            // Add a group for each campaign
            if (modData.Manifest.Missions.Any())
            {
                var yaml = MiniYaml.Merge(modData.Manifest.Missions.Select(
                    m => MiniYaml.FromStream(modData.DefaultFileSystem.Open(m), m)));

                foreach (var kv in yaml)
                {
                    var missionMapPaths = kv.Value.Nodes.Select(n => Path.GetFullPath(n.Key)).ToList();

                    var previews = modData.MapCache
                        .Where(p => p.Status == MapStatus.Available && missionMapPaths.Contains(p.Package.Name))
                        .OrderBy(p => missionMapPaths.IndexOf(p.Package.Name));

                    CreateMissionGroup(kv.Key, previews);
                    allPreviews.AddRange(previews);
                }
            }

            // Add an additional group for loose missions
            var loosePreviews = modData.MapCache
                .Where(p => p.Status == MapStatus.Available && p.Visibility.HasFlag(MapVisibility.MissionSelector) && !allPreviews.Any(a => a.Uid == p.Uid));

            if (loosePreviews.Any())
            {
                CreateMissionGroup("Missions", loosePreviews);
                allPreviews.AddRange(loosePreviews);
            }

            if (allPreviews.Any())
                SelectMap(allPreviews.First());

            // Preload map preview and rules to reduce jank
            new Thread(() =>
            {
                foreach (var p in allPreviews)
                {
                    p.GetMinimap();
                    p.PreloadRules();
                }
            }).Start();

            var startButton = widget.Get<ButtonWidget>("STARTGAME_BUTTON");
            startButton.OnClick = StartMissionClicked;
            startButton.IsDisabled = () => selectedMap == null || selectedMap.InvalidCustomRules;

            widget.Get<ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                StopVideo(videoPlayer);
                Game.Disconnect();
                Ui.CloseWindow();
                onExit();
            };
        }
Ejemplo n.º 22
0
        public static string WrapText(string text, int width, SpriteFont font)
        {
            var textSize = font.Measure(text);
            if (textSize.X > width)
            {
                var lines = text.Split('\n').ToList();

                for (var i=0; i<lines.Count; i++)
                {
                    var line = lines[i];
                    var m = font.Measure(line);

                    if (m.X <= width)
                        continue;

                    var bestSpaceIndex = -1;
                    var start = line.Length - 1;

                    while (m.X > width)
                    {
                        var spaceIndex = line.LastIndexOf(' ', start);
                        if (spaceIndex == -1)
                            break;
                        bestSpaceIndex = spaceIndex;

                        start = spaceIndex - 1;
                        m = font.Measure(line.Substring(0, spaceIndex));
                    }

                    if (bestSpaceIndex != -1)
                    {
                        lines[i] = line.Substring(0, bestSpaceIndex);
                        lines.Insert(i + 1, line.Substring(bestSpaceIndex + 1));
                    }
                }

                return string.Join("\n", lines);
            }
            return text;
        }
Ejemplo n.º 23
0
        public ClientTooltipLogic(Widget widget, TooltipContainerWidget tooltipContainer, OrderManager orderManager, int clientIndex)
        {
            var admin = widget.Get<LabelWidget>("ADMIN");
            var adminFont = Game.Renderer.Fonts[admin.Font];

            var latency = widget.GetOrNull<LabelWidget>("LATENCY");
            if (latency != null)
                latencyFont = Game.Renderer.Fonts[latency.Font];

            var latencyPrefix = widget.GetOrNull<LabelWidget>("LATENCY_PREFIX");
            if (latencyPrefix != null)
                latencyPrefixFont = Game.Renderer.Fonts[latencyPrefix.Font];

            var ip = widget.Get<LabelWidget>("IP");
            var addressFont = Game.Renderer.Fonts[ip.Font];

            var location = widget.Get<LabelWidget>("LOCATION");
            var locationFont = Game.Renderer.Fonts[location.Font];

            var locationOffset = location.Bounds.Y;
            var addressOffset = ip.Bounds.Y;
            var latencyOffset = latency == null ? 0 : latency.Bounds.Y;
            var tooltipHeight = widget.Bounds.Height;

            var margin = widget.Bounds.Width;

            tooltipContainer.IsVisible = () => (orderManager.LobbyInfo.ClientWithIndex(clientIndex) != null);
            tooltipContainer.BeforeRender = () =>
            {
                var latencyPrefixSize = latencyPrefix == null ? 0 : latencyPrefix.Bounds.X + latencyPrefixFont.Measure(latencyPrefix.GetText() + " ").X;
                var locationWidth = locationFont.Measure(location.GetText()).X;
                var adminWidth = adminFont.Measure(admin.GetText()).X;
                var addressWidth = addressFont.Measure(ip.GetText()).X;
                var latencyWidth = latencyFont == null ? 0 : latencyPrefixSize + latencyFont.Measure(latency.GetText()).X;
                var width = Math.Max(locationWidth, Math.Max(adminWidth, Math.Max(addressWidth, latencyWidth)));
                widget.Bounds.Width = width + 2 * margin;
                if (latency != null)
                    latency.Bounds.Width = widget.Bounds.Width;
                ip.Bounds.Width = widget.Bounds.Width;
                admin.Bounds.Width = widget.Bounds.Width;
                location.Bounds.Width = widget.Bounds.Width;

                ip.Bounds.Y = addressOffset;
                if (latency != null)
                    latency.Bounds.Y = latencyOffset;
                location.Bounds.Y = locationOffset;
                widget.Bounds.Height = tooltipHeight;

                if (admin.IsVisible())
                {
                    ip.Bounds.Y += admin.Bounds.Height;
                    if (latency != null)
                        latency.Bounds.Y += admin.Bounds.Height;
                    location.Bounds.Y += admin.Bounds.Height;
                    widget.Bounds.Height += admin.Bounds.Height;
                }

                if (latencyPrefix != null)
                    latencyPrefix.Bounds.Y = latency.Bounds.Y;
                if (latency != null)
                    latency.Bounds.X = latencyPrefixSize;
            };

            admin.IsVisible = () => orderManager.LobbyInfo.ClientWithIndex(clientIndex).IsAdmin;
            var client = orderManager.LobbyInfo.ClientWithIndex(clientIndex);
            var ping = orderManager.LobbyInfo.PingFromClient(client);
            if (latency != null)
            {
                latency.GetText = () => LobbyUtils.LatencyDescription(ping);
                latency.GetColor = () => LobbyUtils.LatencyColor(ping);
            }

            var address = LobbyUtils.GetExternalIP(clientIndex, orderManager);
            var cachedDescriptiveIP = LobbyUtils.DescriptiveIpAddress(address);
            ip.GetText = () => cachedDescriptiveIP;
            var cachedCountryLookup = GeoIP.LookupCountry(address);
            location.GetText = () => cachedCountryLookup;
        }
Ejemplo n.º 24
0
        public override void Draw()
        {
            overlayFont = Game.Renderer.Fonts["TinyBold"];
            timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2;
            queuedOffset = new float2(4,2);
            holdOffset = new float2(32,24) - overlayFont.Measure(HoldText) / 2;
            readyOffset = new float2(32,24) - overlayFont.Measure(ReadyText) / 2;

            if (CurrentQueue == null)
                return;

            var buildableItems = CurrentQueue.BuildableItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);

            // Background
            foreach (var rect in Icons.Keys)
                WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1));

            // Icons
            foreach (var icon in Icons.Values)
            {
                WidgetUtils.DrawSHP(icon.Sprite, icon.Pos, worldRenderer);

                // Build progress
                if (icon.Queued.Count > 0)
                {
                    var first = icon.Queued[0];
                    clock.PlayFetchIndex("idle",
                        () => (first.TotalTime - first.RemainingTime)
                            * (clock.CurrentSequence.Length - 1) / first.TotalTime);
                    clock.Tick();
                    WidgetUtils.DrawSHP(clock.Image, icon.Pos, worldRenderer);
                }
                else if (!buildableItems.Any(a => a.Name == icon.Name))
                    WidgetUtils.DrawSHP(cantBuild.Image, icon.Pos, worldRenderer);
            }

            // Overlays
            foreach (var icon in Icons.Values)
            {
                var total = icon.Queued.Count;
                if (total > 0)
                {
                    var first = icon.Queued[0];
                    var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
                    if (first.Done)
                        overlayFont.DrawTextWithContrast(ReadyText,
                                                         icon.Pos + readyOffset,
                                                         Color.White, Color.Black, 1);
                    else if (first.Paused)
                        overlayFont.DrawTextWithContrast(HoldText,
                                                         icon.Pos + holdOffset,
                                                         Color.White, Color.Black, 1);
                    else if (!waiting)
                        overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual),
                                                         icon.Pos + timeOffset,
                                                         Color.White, Color.Black, 1);

                    if (total > 1 || waiting)
                        overlayFont.DrawTextWithContrast(total.ToString(),
                                                         icon.Pos + queuedOffset,
                                                         Color.White, Color.Black, 1);
                }
            }
        }
Ejemplo n.º 25
0
        public static string WrapText(string text, int width, SpriteFont font)
        {
            var textSize = font.Measure(text);
            if (textSize.X > width)
            {
                var lines = text.Split('\n');
                var newLines = new List<string>();
                var i = 0;
                var line = lines[i++];

                for(;;)
                {
                    newLines.Add(line);
                    var m = font.Measure(line);
                    var spaceIndex = 0;
                    var start = line.Length - 1;

                    if (m.X <= width)
                    {
                        if (i < lines.Length - 1)
                        {
                            line = lines[i++];
                            continue;
                        }
                        else
                            break;
                    }

                    while (m.X > width)
                    {
                        if (-1 == (spaceIndex = line.LastIndexOf(' ', start)))
                            break;
                        start = spaceIndex - 1;
                        m = font.Measure(line.Substring(0, spaceIndex));
                    }

                    if (spaceIndex != -1)
                    {
                        newLines.RemoveAt(newLines.Count - 1);
                        newLines.Add(line.Substring(0, spaceIndex));
                        line = line.Substring(spaceIndex + 1);
                    }
                    else if (i < lines.Length - 1)
                    {
                        line = lines[i++];
                        continue;
                    }
                    else
                        break;
                }
                return string.Join("\n", newLines.ToArray());
            }
            return text;
        }
Ejemplo n.º 26
0
		public override void Draw()
		{
			var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;

			overlayFont = Game.Renderer.Fonts["TinyBold"];
			timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
			queuedOffset = new float2(4, 2);
			holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
			readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;

			if (CurrentQueue == null)
				return;

			var buildableItems = CurrentQueue.BuildableItems();

			var pios = currentQueue.Actor.Owner.PlayerActor.TraitsImplementing<IProductionIconOverlay>();

			// Icons
			foreach (var icon in icons.Values)
			{
				WidgetUtils.DrawSHPCentered(icon.Sprite, icon.Pos + iconOffset, icon.Palette);

				// Draw the ProductionIconOverlay's sprite
				var pio = pios.FirstOrDefault(p => p.IsOverlayActive(icon.Actor));
				if (pio != null)
					WidgetUtils.DrawSHPCentered(pio.Sprite, icon.Pos + iconOffset + pio.Offset(IconSize), worldRenderer.Palette(pio.Palette), 1f);

				// Build progress
				if (icon.Queued.Count > 0)
				{
					var first = icon.Queued[0];
					clock.PlayFetchIndex(ClockSequence,
						() => (first.TotalTime - first.RemainingTime)
							* (clock.CurrentSequence.Length - 1) / first.TotalTime);
					clock.Tick();

					WidgetUtils.DrawSHPCentered(clock.Image, icon.Pos + iconOffset, icon.IconClockPalette);
				}
				else if (!buildableItems.Any(a => a.Name == icon.Name))
					WidgetUtils.DrawSHPCentered(cantBuild.Image, icon.Pos + iconOffset, icon.IconDarkenPalette);
			}

			// Overlays
			foreach (var icon in icons.Values)
			{
				var total = icon.Queued.Count;
				if (total > 0)
				{
					var first = icon.Queued[0];
					var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
					if (first.Done)
					{
						if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber * worldRenderer.World.Timestep / 360 % 2 == 0)
							overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1);
						else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor)
							overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, ReadyTextAltColor, Color.Black, 1);
					}
					else if (first.Paused)
						overlayFont.DrawTextWithContrast(HoldText,
							icon.Pos + holdOffset,
							Color.White, Color.Black, 1);
					else if (!waiting)
						overlayFont.DrawTextWithContrast(WidgetUtils.FormatTime(first.RemainingTimeActual, World.Timestep),
							icon.Pos + timeOffset,
							Color.White, Color.Black, 1);

					if (total > 1 || waiting)
						overlayFont.DrawTextWithContrast(total.ToString(),
							icon.Pos + queuedOffset,
							Color.White, Color.Black, 1);
				}
			}
		}
Ejemplo n.º 27
0
        public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary<string, MiniYaml> logicArgs)
        {
            this.world = world;
            this.modData = modData;
            panel = widget;

            var ticker = panel.GetOrNull<LogicTickerWidget>("ANIMATION_TICKER");
            if (ticker != null)
            {
                ticker.OnTick = () =>
                {
                    if (animateFrames)
                        SelectNextFrame();
                };
            }

            var sourceDropdown = panel.GetOrNull<DropDownButtonWidget>("SOURCE_SELECTOR");
            if (sourceDropdown != null)
            {
                sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown);
                sourceDropdown.GetText = () =>
                {
                    var name = assetSource != null ? Platform.UnresolvePath(assetSource.Name) : "All Packages";
                    if (name.Length > 15)
                        name = "..." + name.Substring(name.Length - 15);

                    return name;
                };
            }

            var spriteWidget = panel.GetOrNull<SpriteWidget>("SPRITE");
            if (spriteWidget != null)
            {
                spriteWidget.GetSprite = () => currentSprites != null ? currentSprites[currentFrame] : null;
                currentPalette = spriteWidget.Palette;
                spriteWidget.GetPalette = () => currentPalette;
                spriteWidget.IsVisible = () => !isVideoLoaded && !IsErrorLabelVisible;
            }

            var playerWidget = panel.GetOrNull<VqaPlayerWidget>("PLAYER");
            if (playerWidget != null)
                playerWidget.IsVisible = () => isVideoLoaded && !IsErrorLabelVisible;

            errorLabelWidget = panel.GetOrNull<LabelWidget>("ERROR");
            if (errorLabelWidget != null)
                errorFont = Game.Renderer.Fonts[errorLabelWidget.Font];

            var paletteDropDown = panel.GetOrNull<DropDownButtonWidget>("PALETTE_SELECTOR");
            if (paletteDropDown != null)
            {
                paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world);
                paletteDropDown.GetText = () => currentPalette;
            }

            var colorPreview = panel.GetOrNull<ColorPreviewManagerWidget>("COLOR_MANAGER");
            if (colorPreview != null)
                colorPreview.Color = Game.Settings.Player.Color;

            var colorDropdown = panel.GetOrNull<DropDownButtonWidget>("COLOR");
            if (colorDropdown != null)
            {
                colorDropdown.IsDisabled = () => currentPalette != colorPreview.PaletteName;
                colorDropdown.OnMouseDown = _ => ColorPickerLogic.ShowColorDropDown(colorDropdown, colorPreview, world);
                panel.Get<ColorBlockWidget>("COLORBLOCK").GetColor = () => Game.Settings.Player.Color.RGB;
            }

            filenameInput = panel.Get<TextFieldWidget>("FILENAME_INPUT");
            filenameInput.OnTextEdited = () => ApplyFilter(filenameInput.Text);
            filenameInput.OnEscKey = filenameInput.YieldKeyboardFocus;

            var frameContainer = panel.GetOrNull("FRAME_SELECTOR");
            if (frameContainer != null)
                frameContainer.IsVisible = () => (currentSprites != null && currentSprites.Length > 1) ||
                    (isVideoLoaded && player != null && player.Video != null && player.Video.Frames > 1);

            frameSlider = panel.Get<SliderWidget>("FRAME_SLIDER");
            if (frameSlider != null)
            {
                frameSlider.OnChange += x =>
                {
                    if (!isVideoLoaded)
                        currentFrame = (int)Math.Round(x);
                };

                frameSlider.GetValue = () => isVideoLoaded ? player.Video.CurrentFrame : currentFrame;
                frameSlider.IsDisabled = () => isVideoLoaded;
            }

            var frameText = panel.GetOrNull<LabelWidget>("FRAME_COUNT");
            if (frameText != null)
            {
                frameText.GetText = () =>
                    isVideoLoaded ?
                    "{0} / {1}".F(player.Video.CurrentFrame + 1, player.Video.Frames) :
                    "{0} / {1}".F(currentFrame, currentSprites.Length - 1);
            }

            var playButton = panel.GetOrNull<ButtonWidget>("BUTTON_PLAY");
            if (playButton != null)
            {
                playButton.Key = new Hotkey(Keycode.SPACE, Modifiers.None);
                playButton.OnClick = () =>
                {
                    if (isVideoLoaded)
                        player.Play();
                    else
                        animateFrames = true;
                };

                playButton.IsVisible = () => isVideoLoaded ? player.Paused : !animateFrames;
            }

            var pauseButton = panel.GetOrNull<ButtonWidget>("BUTTON_PAUSE");
            if (pauseButton != null)
            {
                pauseButton.Key = new Hotkey(Keycode.SPACE, Modifiers.None);
                pauseButton.OnClick = () =>
                {
                    if (isVideoLoaded)
                        player.Pause();
                    else
                        animateFrames = false;
                };

                pauseButton.IsVisible = () => isVideoLoaded ? !player.Paused : animateFrames;
            }

            var stopButton = panel.GetOrNull<ButtonWidget>("BUTTON_STOP");
            if (stopButton != null)
            {
                stopButton.Key = new Hotkey(Keycode.RETURN, Modifiers.None);
                stopButton.OnClick = () =>
                {
                    if (isVideoLoaded)
                        player.Stop();
                    else
                    {
                        frameSlider.Value = 0;
                        currentFrame = 0;
                        animateFrames = false;
                    }
                };
            }

            var nextButton = panel.GetOrNull<ButtonWidget>("BUTTON_NEXT");
            if (nextButton != null)
            {
                nextButton.Key = new Hotkey(Keycode.RIGHT, Modifiers.None);
                nextButton.OnClick = () =>
                {
                    if (!isVideoLoaded)
                        nextButton.OnClick = SelectNextFrame;
                };

                nextButton.IsVisible = () => !isVideoLoaded;
            }

            var prevButton = panel.GetOrNull<ButtonWidget>("BUTTON_PREV");
            if (prevButton != null)
            {
                prevButton.Key = new Hotkey(Keycode.LEFT, Modifiers.None);
                prevButton.OnClick = () =>
                {
                    if (!isVideoLoaded)
                        SelectPreviousFrame();
                };

                prevButton.IsVisible = () => !isVideoLoaded;
            }

            if (logicArgs.ContainsKey("SupportedFormats"))
                allowedExtensions = FieldLoader.GetValue<string[]>("SupportedFormats", logicArgs["SupportedFormats"].Value);
            else
                allowedExtensions = new string[0];

            acceptablePackages = modData.ModFiles.MountedPackages.Where(p =>
                p.Contents.Any(c => allowedExtensions.Contains(Path.GetExtension(c).ToLowerInvariant())));

            assetList = panel.Get<ScrollPanelWidget>("ASSET_LIST");
            template = panel.Get<ScrollItemWidget>("ASSET_TEMPLATE");
            PopulateAssetList();

            var closeButton = panel.GetOrNull<ButtonWidget>("CLOSE_BUTTON");
            if (closeButton != null)
                closeButton.OnClick = () =>
                {
                    if (isVideoLoaded)
                        player.Stop();
                    Ui.CloseWindow();
                    onExit();
                };
        }
Ejemplo n.º 28
-2
 public CashTick(WPos pos, Color color, int value)
 {
     this.font = Game.Renderer.Fonts["TinyBold"];
     this.pos = pos;
     this.color = color;
     this.text = "{0}${1}".F(value < 0 ? "-" : "+", Math.Abs(value));
 }