Пример #1
0
        IEnumerable <IRenderable> IRenderAboveShroudWhenSelected.RenderAboveShroud(Actor self, WorldRenderer wr)
        {
            var color = Color.FromArgb(info.Transparency, info.UsePlayerColor ? self.Owner.Color : info.Color);

            if (mindController != null)
            {
                foreach (var s in mindController.Slaves)
                {
                    yield return(new ArcRenderable(
                                     self.CenterPosition + info.Offset,
                                     s.CenterPosition + info.Offset,
                                     info.ZOffset, info.Angle, color, info.Width, info.QuantizedSegments));
                }
                yield break;
            }

            if (mindControllable == null || mindControllable.Master == null || !mindControllable.Master.IsInWorld)
            {
                yield break;
            }

            yield return(new ArcRenderable(
                             mindControllable.Master.CenterPosition + info.Offset,
                             self.CenterPosition + info.Offset,
                             info.ZOffset, info.Angle, color, info.Width, info.QuantizedSegments));
        }
Пример #2
0
        void ShowLightDiffuseColorDropDown(DropDownButtonWidget color, ColorPreviewManagerWidget preview, World world)
        {
            Action onExit = () =>
            {
                Color c = preview.Color;
                lightDiffuseColor[0]            = float.Parse((Convert.ToSingle(c.R) / 255).ToString("0.0"));
                lightDiffuseColor[1]            = float.Parse((Convert.ToSingle(c.G) / 255).ToString("0.0"));
                lightDiffuseColor[2]            = float.Parse((Convert.ToSingle(c.B) / 255).ToString("0.0"));
                lightDiffuseColorBlock.GetColor = () => c;
                lightDiffuseColorValue.GetText  = () => string.Format("{0}, {1}, {2}", lightDiffuseColor[0].ToString(), lightDiffuseColor[1].ToString(), lightDiffuseColor[2].ToString());
            };

            color.RemovePanel();

            Action <Color> onChange = c => preview.Color = c;

            var colorChooser = Game.LoadWidget(world, "COLOR_CHOOSER", null, new WidgetArgs()
            {
                { "onChange", onChange },
                { "initialColor", Color.FromArgb(
                      Convert.ToInt32(lightDiffuseColor[0] * 255),
                      Convert.ToInt32(lightDiffuseColor[1] * 255),
                      Convert.ToInt32(lightDiffuseColor[2] * 255)
                      ) },
                { "initialFaction", null }
            });

            color.AttachPanel(colorChooser, onExit);
        }
        public void AdjustPalette(IReadOnlyDictionary<string, MutablePalette> palettes)
        {
            if (remainingFrames == 0)
                return;

            foreach (var pal in palettes)
            {
                if (info.ExcludePalette.Contains(pal.Key))
                {
                    continue;
                }
                for (var x = 0; x < Palette.Size; x++)
                {
                    var orig = pal.Value.GetColor(x);
                    var c = Info.Color;
                    var color = Color.FromArgb(orig.A, ((int)c.R).Clamp(0, 255), ((int)c.G).Clamp(0, 255), ((int)c.B).Clamp(0, 255));
                    var final = GUtil.PremultipliedColorLerp(info.Ratio, orig, GUtil.PremultiplyAlpha(Color.FromArgb(orig.A, color)));
                    pal.Value.SetColor(x, final);
                }
            }
        }
Пример #4
0
        public VxlBrowserLogic(Widget widget, Action onExit, ModData modData, World world, Dictionary <string, MiniYaml> logicArgs)
        {
            this.world   = world;
            this.modData = modData;
            panel        = widget;

            var voxelWidget = panel.GetOrNull <VoxelWidget>("VOXEL");

            if (voxelWidget != null)
            {
                voxelWidget.GetVoxel             = () => currentVoxel != null ? currentVoxel : null;
                currentPalette                   = voxelWidget.Palette;
                voxelWidget.GetPalette           = () => currentPalette;
                voxelWidget.GetPlayerPalette     = () => currentPlayerPalette;
                voxelWidget.GetNormalsPalette    = () => currentNormalsPalette;
                voxelWidget.GetShadowPalette     = () => currentShadowPalette;
                voxelWidget.GetLightAmbientColor = () => lightAmbientColor;
                voxelWidget.GetLightDiffuseColor = () => lightDiffuseColor;
                voxelWidget.GetLightPitch        = () => lightPitch;
                voxelWidget.GetLightYaw          = () => lightYaw;
                voxelWidget.IsVisible            = () => !isVideoLoaded && !isLoadError;
            }

            var playerWidget = panel.GetOrNull <VqaPlayerWidget>("PLAYER");

            if (playerWidget != null)
            {
                playerWidget.IsVisible = () => isVideoLoaded && !isLoadError;
            }

            var paletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PALETTE_SELECTOR");

            if (paletteDropDown != null)
            {
                paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world);
                paletteDropDown.GetText     = () => currentPalette;
            }

            var lightAmbientColorPreview = panel.GetOrNull <ColorPreviewManagerWidget>("LIGHT_AMBIENT_COLOR_MANAGER");

            if (lightAmbientColorPreview != null)
            {
                lightAmbientColorPreview.Color = Color.FromArgb(
                    Convert.ToInt32(lightAmbientColor[0] * 255),
                    Convert.ToInt32(lightAmbientColor[1] * 255),
                    Convert.ToInt32(lightAmbientColor[2] * 255)
                    );
            }

            var lightDiffuseColorPreview = panel.GetOrNull <ColorPreviewManagerWidget>("LIGHT_DIFFUSE_COLOR_MANAGER");

            if (lightDiffuseColorPreview != null)
            {
                lightDiffuseColorPreview.Color = Color.FromArgb(
                    Convert.ToInt32(lightDiffuseColor[0] * 255),
                    Convert.ToInt32(lightDiffuseColor[1] * 255),
                    Convert.ToInt32(lightDiffuseColor[2] * 255)
                    );
            }

            var playerPaletteDropDown = panel.GetOrNull <DropDownButtonWidget>("PLAYER_PALETTE_SELECTOR");

            if (playerPaletteDropDown != null)
            {
                playerPaletteDropDown.OnMouseDown = _ => ShowPlayerPaletteDropdown(playerPaletteDropDown, world);
                playerPaletteDropDown.GetText     = () => currentPlayerPalette;
            }

            var normalsPlaletteDropDown = panel.GetOrNull <DropDownButtonWidget>("NORMALS_PALETTE_SELECTOR");

            if (normalsPlaletteDropDown != null)
            {
                normalsPlaletteDropDown.OnMouseDown = _ => ShowNormalsPaletteDropdown(normalsPlaletteDropDown, world);
                normalsPlaletteDropDown.GetText     = () => currentNormalsPalette;
            }

            var shadowPlaletteDropDown = panel.GetOrNull <DropDownButtonWidget>("SHADOW_PALETTE_SELECTOR");

            if (shadowPlaletteDropDown != null)
            {
                shadowPlaletteDropDown.OnMouseDown = _ => ShowShadowPaletteDropdown(normalsPlaletteDropDown, world);
                shadowPlaletteDropDown.GetText     = () => currentShadowPalette;
            }

            scaleInput = panel.GetOrNull <TextFieldWidget>("SCALE_TEXT");
            scaleInput.OnTextEdited = () => OnScaleEdit();
            scaleInput.OnEscKey     = scaleInput.YieldKeyboardFocus;

            lightPitchInput = panel.GetOrNull <TextFieldWidget>("LIGHTPITCH_TEXT");
            lightPitchInput.OnTextEdited = () => OnLightPitchEdit();
            lightPitchInput.OnEscKey     = lightPitchInput.YieldKeyboardFocus;

            lightYawInput = panel.GetOrNull <TextFieldWidget>("LIGHTYAW_TEXT");
            lightYawInput.OnTextEdited = () => OnLightYawEdit();
            lightYawInput.OnEscKey     = lightYawInput.YieldKeyboardFocus;


            var lightAmbientColorDropDown = panel.GetOrNull <DropDownButtonWidget>("LIGHT_AMBIENT_COLOR");

            if (lightAmbientColorDropDown != null)
            {
                lightAmbientColorDropDown.OnMouseDown = _ => ShowLightAmbientColorDropDown(lightAmbientColorDropDown, lightAmbientColorPreview, world);
                lightAmbientColorBlock          = panel.Get <ColorBlockWidget>("AMBIENT_COLORBLOCK");
                lightAmbientColorBlock.GetColor = () => OpenRA.Primitives.Color.FromArgb(
                    Convert.ToInt32(lightAmbientColor[0] * 255),
                    Convert.ToInt32(lightAmbientColor[1] * 255),
                    Convert.ToInt32(lightAmbientColor[2] * 255)
                    );
            }

            lightAmbientColorValue = panel.GetOrNull <LabelWidget>("LIGHTAMBIENTCOLOR_VALUE");
            lightDiffuseColorValue = panel.GetOrNull <LabelWidget>("LIGHTDIFFUSECOLOR_VALUE");

            var lightDiffuseColorDropDown = panel.GetOrNull <DropDownButtonWidget>("LIGHT_DIFFUSE_COLOR");

            if (lightDiffuseColorDropDown != null)
            {
                lightDiffuseColorDropDown.OnMouseDown = _ => ShowLightDiffuseColorDropDown(lightDiffuseColorDropDown, lightDiffuseColorPreview, world);
                lightDiffuseColorBlock          = panel.Get <ColorBlockWidget>("DIFFUSE_COLORBLOCK");
                lightDiffuseColorBlock.GetColor = () => Color.FromArgb(
                    Convert.ToInt32(lightDiffuseColor[0] * 255),
                    Convert.ToInt32(lightDiffuseColor[1] * 255),
                    Convert.ToInt32(lightDiffuseColor[2] * 255)
                    );
            }

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

            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())));

            unitList = 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();
                }
            }
            ;
        }