Beispiel #1
0
 public override void MouseEnter()
 {
     if (Sensitive && (Flags & ElementFlags.RespondToMouse) == ElementFlags.RespondToMouse)
     {
         /* highlight the text */
         GuiUtil.PlaySound(Mpq, Builtins.MouseoverWav);
     }
     base.MouseEnter();
 }
Beispiel #2
0
        void ShowGameModeDialog(UIScreenType nextScreen)
        {
            GameModeDialog d = new GameModeDialog(this, mpq);

            d.Cancel   += delegate() { DismissDialog(); };
            d.Activate += delegate(bool expansion) {
                DismissDialog();
                try {
                    Game.Instance.PlayingBroodWar = expansion;
                    GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav);
                    Game.Instance.SwitchToScreen(nextScreen);
                }
                catch (Exception e) {
                    ShowDialog(new OkDialog(this, mpq, e.Message));
                }
            };
            ShowDialog(d);
        }
Beispiel #3
0
        protected override void ResourceLoader()
        {
            base.ResourceLoader();
            for (int i = 0; i < Elements.Count; i++)
            {
                Console.WriteLine("{0}: {1} '{2}' : {3}", i, Elements[i].Type, Elements[i].Text, Elements[i].Flags);
            }

            //Elements[VERSION_ELEMENT_INDEX].Text = "v" + Consts.Version;

            Elements[SINGLEPLAYER_ELEMENT_INDEX].Flags |= ElementFlags.RightAlignText | ElementFlags.CenterTextVert;

            Elements[SINGLEPLAYER_ELEMENT_INDEX].Activate +=
                delegate() {
                if (Game.Instance.IsBroodWar)
                {
                    ShowGameModeDialog(UIScreenType.Login);
                }
                else
                {
                    GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav);
                    Game.Instance.SwitchToScreen(UIScreenType.Login);
                }
            };

            Elements[MULTIPLAYER_ELEMENT_INDEX].Activate +=
                delegate() {
                if (Game.Instance.IsBroodWar)
                {
                    ShowGameModeDialog(UIScreenType.Connection);
                }
                else
                {
                    GuiUtil.PlaySound(mpq, Builtins.Mousedown2Wav);
                    Game.Instance.SwitchToScreen(UIScreenType.Connection);
                }
            };

            Elements[CAMPAIGNEDITOR_ELEMENT_INDEX].Activate +=
                delegate() {
                OkDialog d = new OkDialog(this, mpq,
                                          "The campaign editor functionality is not available in SCSharp");
                ShowDialog(d);
            };

            Elements[INTRO_ELEMENT_INDEX].Activate +=
                delegate() {
                Cinematic introScreen = new Cinematic(mpq,
                                                      Game.Instance.IsBroodWar
                                                                               ? "smk\\starXIntr.smk"
                                                                               : "smk\\starintr.smk");
                introScreen.Finished += delegate() {
                    Game.Instance.SwitchToScreen(this);
                };
                Game.Instance.SwitchToScreen(introScreen);
            };

            Elements[CREDITS_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.SwitchToScreen(new CreditsScreen(mpq));
            };

            Elements[EXIT_ELEMENT_INDEX].Activate +=
                delegate() {
                Game.Instance.Quit();
            };

            smkElements = new List <UIElement>();

            AddMovieElements(SINGLEPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Single.smk", "glue\\mainmenu\\SingleOn.smk", 45, 66, false);
            AddMovieElements(MULTIPLAYER_ELEMENT_INDEX, "glue\\mainmenu\\Multi.smk", "glue\\mainmenu\\MultiOn.smk", 20, 10, true);
            AddMovieElements(CAMPAIGNEDITOR_ELEMENT_INDEX, "glue\\mainmenu\\Editor.smk", "glue\\mainmenu\\EditorOn.smk", 20, 16, true);
            AddMovieElements(EXIT_ELEMENT_INDEX, "glue\\mainmenu\\Exit.smk", "glue\\mainmenu\\ExitOn.smk", 15, 0, true);

            foreach (var ui_el in smkElements)
            {
                ui_el.Layer.Position    = new PointF(ui_el.X1, Bounds.Height - ui_el.Y1 - ui_el.Layer.Bounds.Height);
                ui_el.Layer.AnchorPoint = new PointF(0, 0);
                AddSublayer(ui_el.Layer);
            }
        }
Beispiel #4
0
        public void Tick(object sender, TickEventArgs e)
        {
            TriggerAction[] actions = triggerData.Triggers[0].Actions;

            if (current_action == actions.Length)
            {
                return;
            }

            // FIXME we need to figure out how many ticks per second SC1 used for normal mode... 6?

            totalElapsed += (int)e.MillisecondsElapsed;

            /* if we're presently waiting, make sure
             * enough time has gone by.  otherwise
             * return */
            if (totalElapsed < sleepUntil * 166 /* 166 = 1/6th of a second */)
            {
                return;
            }

            totalElapsed = 0;

            while (current_action < actions.Length)
            {
                TriggerAction action = actions[current_action];

                current_action++;

                switch (action.Action)
                {
                case 0:                 /* no action */
                    break;

                case 1:
                    sleepUntil = (int)action.Delay;
                    return;

                case 2:
                    GuiUtil.PlaySound(screen.Mpq, prefix + "\\" + scenario.GetMapString((int)action.WavIndex));
                    sleepUntil = (int)action.Delay;
                    return;

                case 3:
                    screen.SetTransmissionText(scenario.GetMapString((int)action.TextIndex));
                    break;

                case 4:
                    screen.SetObjectives(scenario.GetMapString((int)action.TextIndex));
                    break;

                case 5:
                    Console.WriteLine("show portrait:");
                    Console.WriteLine("location = {0}, textindex = {1}, wavindex = {2}, delay = {3}, group1 = {4}, group2 = {5}, unittype = {6}, action = {7}, switch = {8}, flags = {9}",
                                      action.Location,
                                      action.TextIndex,
                                      action.WavIndex,
                                      action.Delay,
                                      action.Group1,
                                      action.Group2,
                                      action.UnitType,
                                      action.Action,
                                      action.Switch,
                                      action.Flags);
                    screen.ShowPortrait((int)action.UnitType, (int)action.Group1);
                    Console.WriteLine(scenario.GetMapString((int)action.TextIndex));
                    break;

                case 6:
                    screen.HidePortrait((int)action.Group1);
                    break;

                case 7:
                    Console.WriteLine("Display Speaking Portrait(Slot, Time)");
                    Console.WriteLine(scenario.GetMapString((int)action.TextIndex));
                    break;

                case 8:
                    Console.WriteLine("Transmission(Text, Slot, Time, Modifier, Wave, WavTime)");
                    screen.SetTransmissionText(scenario.GetMapString((int)action.TextIndex));
                    screen.HighlightPortrait((int)action.Group1);
                    GuiUtil.PlaySound(screen.Mpq, prefix + "\\" + scenario.GetMapString((int)action.WavIndex));
                    sleepUntil = (int)action.Delay;
                    return;

                default:
                    break;
                }
            }
        }
Beispiel #5
0
        public override void MouseButtonDown(MouseButtonEventArgs args)
        {
            if (mouseOverElement != null)
            {
                base.MouseButtonDown(args);
            }
            else if (args.X > MINIMAP_X && args.X < MINIMAP_X + MINIMAP_WIDTH &&
                     args.Y > MINIMAP_Y && args.Y < MINIMAP_Y + MINIMAP_HEIGHT)
            {
                RecenterFromMinimap(args.X, args.Y);
                buttonDownInMinimap = true;
            }
            else
            {
                if (selectedUnit != unitUnderCursor)
                {
                    Console.WriteLine("hey there, keyboard.modifierkeystate = {0}", Keyboard.ModifierKeyState);

                    // if we have a selected unit and we
                    // right click (or ctrl-click?), try
                    // to move there
                    if (selectedUnit != null && (Keyboard.ModifierKeyState & ModifierKeys.ShiftKeys) != 0)
                    {
                        Console.WriteLine("And... we're walking");

                        int pixel_x = args.X + topleft_x;
                        int pixel_y = args.Y + topleft_y;

                        // calculate the megatile
                        int megatile_x = pixel_x >> 5;
                        int megatile_y = pixel_y >> 5;

                        Console.WriteLine("megatile {0},{1}", megatile_x, megatile_y);

                        // the mini tile
                        int minitile_x = pixel_x >> 2;
                        int minitile_y = pixel_y >> 2;

                        Console.WriteLine("minitile {0},{1} ({2},{3} in the megatile)",
                                          minitile_x, minitile_y,
                                          minitile_x - megatile_x * 8,
                                          minitile_y - megatile_y * 8);

                        if (selectedUnit.YesSound != null)
                        {
                            string sound_resource = String.Format("sound\\{0}", selectedUnit.YesSound);
                            Console.WriteLine("sound_resource = {0}", sound_resource);
                            GuiUtil.PlaySound(mpq, sound_resource);
                        }

                        selectedUnit.Move(mapRenderer, minitile_x, minitile_y);

                        return;
                    }

                    portraitElement.Stop();

                    selectedUnit = unitUnderCursor;

                    if (selectedUnit == null)
                    {
                        portraitElement.Visible  = false;
                        wireframeElement.Visible = false;
                        for (int i = 0; i < (int)HudLabels.Count; i++)
                        {
                            labelElements[i].Visible = false;
                        }
                    }
                    else
                    {
                        Console.WriteLine("selected unit: {0}", selectedUnit);
                        Console.WriteLine("selectioncircle = {0}", selectedUnit.SelectionCircleOffset);

                        if (selectedUnit.Portrait == null)
                        {
                            portraitElement.Visible = false;
                        }
                        else
                        {
                            string portrait_resource = String.Format("portrait\\{0}0.smk",
                                                                     selectedUnit.Portrait);

                            portraitElement.Player = new SmackerPlayer((Stream)mpq.GetResource(portrait_resource), 1);
                            portraitElement.Play();
                            portraitElement.Visible = true;
                        }

                        if (selectedUnit.WhatSound != null)
                        {
                            string sound_resource = String.Format("sound\\{0}", selectedUnit.WhatSound);
                            Console.WriteLine("sound_resource = {0}", sound_resource);
                            GuiUtil.PlaySound(mpq, sound_resource);
                        }

                        /* set up the wireframe */
                        wireframeElement.Frame   = selectedUnit.UnitId;
                        wireframeElement.Visible = true;

                        /* then display info about the selected unit */
                        labelElements[(int)HudLabels.UnitName].Text = statTxt[selectedUnit.UnitId];
                        if (true /* XXX unit is a building */)
                        {
                            labelElements[(int)HudLabels.ResourceUsed].Text     = statTxt[820 + (int)Game.Instance.Race];
                            labelElements[(int)HudLabels.ResourceProvided].Text = statTxt[814 + (int)Game.Instance.Race];
                            labelElements[(int)HudLabels.ResourceTotal].Text    = statTxt[817 + (int)Game.Instance.Race];
                            labelElements[(int)HudLabels.ResourceMax].Text      = statTxt[823 + (int)Game.Instance.Race];

                            for (int i = 0; i < (int)HudLabels.Count; i++)
                            {
                                labelElements[i].Visible = true;
                            }
                        }

                        /* then fill in the command buttons */
                        int[] cmd_indices;

                        switch (selectedUnit.UnitId)
                        {
                        case 106:
                            cmd_indices = new int[] { 7, -1, -1, -1, -1, 286, -1, -1, 282 };
                            break;

                        default:
                            Console.WriteLine("cmd_indices == -1");
                            cmd_indices = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1 };
                            break;
                        }

                        for (int i = 0; i < cmd_indices.Length; i++)
                        {
                            if (cmd_indices[i] == -1)
                            {
                                cmdButtonElements[i].Visible = false;
                            }
                            else
                            {
                                cmdButtonElements[i].Visible = true;
                                cmdButtonElements[i].Frame   = cmd_indices[i];
                            }
                        }
                    }
                }
            }
        }