Beispiel #1
0
        public override EffectLayer Render(IGameState state)
        {
            EffectLayer bg_layer = new EffectLayer("Elite: Dangerous - Background");

            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            Color combat_bg_color = gameState.Status.IsFlagSet(Flag.HUD_DISCOVERY_MODE) ? this.Properties.DiscoveryModeColor : this.Properties.CombatModeColor;

            bg_layer.Fill(combat_bg_color);

            return(bg_layer);
        }
        public override EffectLayer Render(IGameState state)
        {
            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            GSI.Nodes.Controls controls = (state as GameState_EliteDangerous).Controls;

            EffectLayer          keyBindsLayer       = new EffectLayer("Elite: Dangerous - Key Binds");
            HashSet <DeviceKeys> leftoverBlendStates = new HashSet <DeviceKeys>(keyBlendStates.Keys);

            long currentTime = Utils.Time.GetMillisecondsSinceEpoch();

            if (gameState.Journal.fsdWaitingCooldown && gameState.Status.IsFlagSet(Flag.FSD_COOLDOWN))
            {
                gameState.Journal.fsdWaitingCooldown = false;
            }

            if (gameState.Journal.fsdWaitingSupercruise && gameState.Status.IsFlagSet(Flag.SUPERCRUISE))
            {
                gameState.Journal.fsdWaitingSupercruise = false;
            }

            Color newKeyColor;
            Dictionary <DeviceKeys, Color> smoothColorSets = new Dictionary <DeviceKeys, Color>();

            foreach (ControlGroupSet controlGroupSet in controlGroupSets)
            {
                if (!controlGroupSet.IsSatisfied(gameState))
                {
                    continue;
                }

                foreach (ControlGroup controlGroup in controlGroupSet.controlGroups)
                {
                    if (!controlGroup.IsSatisfied(gameState))
                    {
                        continue;
                    }

                    foreach (string command in controlGroup.commands)
                    {
                        if (!controls.commandToBind.ContainsKey(command))
                        {
                            continue;
                        }

                        bool keyWithEffect = KeyPresets.KEY_EFFECTS.ContainsKey(command);

                        foreach (Bind.Mapping mapping in controls.commandToBind[command].mappings)
                        {
                            bool allModifiersPressed = true;
                            foreach (DeviceKeys modifierKey in mapping.modifiers)
                            {
                                SetKey(keyBindsLayer, modifierKey, Properties.ShipStuffColor);
                                leftoverBlendStates.Remove(modifierKey);
                                if (Array.IndexOf(
                                        Global.InputEvents.PressedKeys,
                                        KeyUtils.GetFormsKey(modifierKey)
                                        ) == -1)
                                {
                                    allModifiersPressed = false;
                                    break;
                                }
                            }

                            if (!allModifiersPressed)
                            {
                                continue;
                            }

                            newKeyColor = Properties.GetColorByGroupName(
                                controlGroup.colorGroupName ?? CommandColors.GetColorGroupForCommand(command)
                                );

                            if (keyWithEffect)
                            {
                                SetKey(keyBindsLayer, mapping.key, KeyPresets.KEY_EFFECTS[command](newKeyColor, gameState, currentTime));
                            }
                            else
                            {
                                smoothColorSets[mapping.key] = newKeyColor;
                            }

                            leftoverBlendStates.Remove(mapping.key);
                        }
                    }
                }
            }

            //Apply smooth transitions for keys
            foreach (KeyValuePair <DeviceKeys, Color> smoothKey in smoothColorSets)
            {
                SetKeySmooth(keyBindsLayer, smoothKey.Key, smoothKey.Value);
            }

            //Fade out inactive keys
            foreach (DeviceKeys key in leftoverBlendStates)
            {
                SetKeySmooth(keyBindsLayer, key, Color.Empty);
            }

            return(keyBindsLayer);
        }
Beispiel #3
0
        public override EffectLayer Render(IGameState state)
        {
            GameState_EliteDangerous gameState = state as GameState_EliteDangerous;

            previousTime = currentTime;
            currentTime  = Time.GetMillisecondsSinceEpoch();

            EffectLayer animation_layer = new EffectLayer("Elite: Dangerous - Animations");

            if (gameState.Journal.ExitStarClass != StarClass.None)
            {
                RegenerateHyperspaceExitAnimation(gameState.Journal.ExitStarClass);
                gameState.Journal.ExitStarClass = StarClass.None;
                animateOnce        = EliteAnimation.HyperspaceExit;
                totalAnimationTime = 0;
                animationKeyframe  = 0;
            }

            if (animateOnce != EliteAnimation.None)
            {
                currentAnimation = animateOnce;
            }
            else if (gameState.Journal.fsdState == FSDState.Idle)
            {
                currentAnimation = EliteAnimation.None;
            }
            else if (gameState.Journal.fsdState == FSDState.CountdownSupercruise || gameState.Journal.fsdState == FSDState.CountdownHyperspace)
            {
                currentAnimation = EliteAnimation.FsdCountdowm;
            }
            else if (gameState.Journal.fsdState == FSDState.InHyperspace)
            {
                currentAnimation = EliteAnimation.Hyperspace;
            }

            if (currentAnimation == EliteAnimation.None)
            {
                animationKeyframe  = 0;
                totalAnimationTime = 0;
            }

            if ((currentAnimation != EliteAnimation.None && currentAnimation != EliteAnimation.HyperspaceExit) || gameState.Journal.fsdWaitingSupercruise)
            {
                BgFadeIn(animation_layer);
            }
            else if (layerFadeState > 0)
            {
                BgFadeOut(animation_layer);
            }

            float deltaTime = 0f, currentAnimationDuration = 0f;

            if (currentAnimation == EliteAnimation.FsdCountdowm)
            {
                currentAnimationDuration = fsd_countdown_mix.GetDuration();
                fsd_countdown_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                deltaTime          = getDeltaTime();
                animationKeyframe += deltaTime;
            }
            else if (currentAnimation == EliteAnimation.Hyperspace)
            {
                currentAnimationDuration = hyperspace_mix.GetDuration();
                hyperspace_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                hyperspace_mix.Draw(animation_layer.GetGraphics(), findMod(animationKeyframe + 1.2f, currentAnimationDuration));
                hyperspace_mix.Draw(animation_layer.GetGraphics(), findMod(animationKeyframe + 2.8f, currentAnimationDuration));
                deltaTime = getDeltaTime();
                //Loop the animation
                animationKeyframe = findMod(animationKeyframe + (deltaTime), currentAnimationDuration);
            }
            else if (currentAnimation == EliteAnimation.HyperspaceExit)
            {
                currentAnimationDuration = hypespace_exit_mix.GetDuration();
                hypespace_exit_mix.Draw(animation_layer.GetGraphics(), animationKeyframe);
                deltaTime = getDeltaTime();

                animationKeyframe += deltaTime;
            }

            totalAnimationTime += deltaTime;
            if (totalAnimationTime > currentAnimationDuration)
            {
                animateOnce = EliteAnimation.None;
            }

            return(animation_layer);
        }