Beispiel #1
0
        public override void RunTick(WEScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            if (this.activity == true)
            {
                // If left-mouse is released, end the selection:
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Released)
                {
                    this.EndSelection();
                }
            }

            else
            {
                // If left-mouse clicks, start the selection or drag an existing one:
                if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
                {
                    this.StartSelection(Cursor.MiniGridX, Cursor.MiniGridY);
                }
            }
        }
Beispiel #2
0
 public WEScroller(UIComponent parent, WEScene scene, short posX, short posY) : base(parent)
 {
     this.scene = scene;
     this.SetWidth((byte)WorldmapEnum.TileWidth + 4);
     this.SetHeight((short)Systems.screen.viewHeight);
     this.SetRelativePosition(posX, posY);
 }
Beispiel #3
0
        public TutorialWorldEdit(WEScene scene) : base()
        {
            this.scene        = scene;
            this.tutorialStep = (short)(Systems.settings.tutorial.WorldEditor);

            this.tutorialMethods = new Dictionary <short, Action>();
            this.tutorialMethods.Add(0, this.SelectingTiles);
            this.tutorialMethods.Add(1, this.PlacingTiles);
            this.tutorialMethods.Add(2, this.PlacingTerrainNotes);
            this.tutorialMethods.Add(3, this.ScrollerBar);
            this.tutorialMethods.Add(4, this.TabMenu);
            this.tutorialMethods.Add(5, this.TabMenuUse);
            this.tutorialMethods.Add(6, this.CloningTiles);
            this.tutorialMethods.Add(7, this.EraseTiles);
            this.tutorialMethods.Add(8, this.OpenConsole);
            this.tutorialMethods.Add(9, this.ResizeLevel);
            this.tutorialMethods.Add(10, this.SetWorldName);
            this.tutorialMethods.Add(11, this.FasterMove);
            this.tutorialMethods.Add(12, this.ChangeZone);
            this.tutorialMethods.Add(13, this.HomeZone);
            this.tutorialMethods.Add(14, this.PlaceLevelNode);
            this.tutorialMethods.Add(15, this.WandTool);
            this.tutorialMethods.Add(16, this.ChangeLevelID);
            this.tutorialMethods.Add(17, this.PlaceCharacter);
            this.tutorialMethods.Add(18, this.SaveWorld);
            this.tutorialMethods.Add(19, this.PlayWorld);
        }
Beispiel #4
0
        public static void SetDescription()
        {
            string  text  = Sanitize.Description(ConsoleTrack.instructionText.Substring(4).TrimStart());
            WEScene scene = (WEScene)Systems.scene;

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "desc " + text.Substring(0, Math.Min(text.Length, 72));
            }

            short remain = (short)(72 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `desc This world is awesome. You will love it.`";
            ConsoleTrack.helpText     = "Provide a description. Currently: \"" + scene.worldData.description + "\". " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 72)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Description", "World description must be 72 characters or less.", 240);
                    return;
                }

                scene.worldContent.data.description = text;
                UIHandler.AddNotification(UIAlertType.Success, "New World Description", "Description Set: \"" + text + "\"", 240);
            }
        }
Beispiel #5
0
 public virtual void RunTick(WEScene scene)
 {
     if (UIComponent.ComponentWithFocus != null)
     {
         return;
     }
 }
Beispiel #6
0
 public WEUtilityBar(UIComponent parent, WEScene scene, short posX, short posY) : base(parent)
 {
     this.scene = scene;
     this.SetWidth(((byte)WorldmapEnum.TileWidth + 2) * (byte)WEUtilityBarEnum.BarTiles);
     this.SetHeight((byte)WorldmapEnum.TileHeight);
     this.SetRelativePosition(posX, posY);
 }
Beispiel #7
0
        public override void ActivateWorldFuncButton()
        {
            WEScene scene = (WEScene)Systems.scene;

            scene.SwitchZone(0);
            GameValues.LastAction = "WEHomeButton";
        }
Beispiel #8
0
        public static void UpdateHelperText()
        {
            if (Systems.scene is WEScene == false)
            {
                return;
            }
            WEScene WEScene = (WEScene)Systems.scene;

            // Tile Tool Helper Text
            if (WETools.WETileTool != null)
            {
                WEPlaceholder ph = WETools.WETileTool.CurrentPlaceholder;

                if (ph.obj > 0)
                {
                    // Object ID
                    if (WEShadowTile.HelpText.ContainsKey(ph.obj))
                    {
                        string[] help = WEShadowTile.HelpText[ph.obj];
                        WEScene.weUI.statusText.SetText(help[0], help[1]);
                        return;
                    }
                }
            }

            WEScene.weUI.statusText.ClearStatus();
        }
Beispiel #9
0
        public static void SetTitle()
        {
            string  text  = Sanitize.Title(ConsoleTrack.instructionText.Substring(5).TrimStart());
            WEScene scene = (WEScene)Systems.scene;

            if (text.Length > 0)
            {
                ConsoleTrack.instructionText = "title " + text.Substring(0, Math.Min(text.Length, 24));
            }

            short remain = (short)(24 - text.Length);

            ConsoleTrack.possibleTabs = "Example: `title My World`";
            ConsoleTrack.helpText     = "Provide a world title. Currently: \"" + scene.worldData.title + "\". " + remain.ToString() + " characters remaining.";

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                // Prevent Rename if it exceeds name length.
                if (text.Length > 24)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Title", "Title must be 24 characters or less.", 240);
                    return;
                }

                scene.worldContent.data.title = text;
                UIHandler.AddNotification(UIAlertType.Success, "New World Title", "World title set to: \"" + text + "\"", 240);
            }
        }
Beispiel #10
0
        public static void SetLevel()
        {
            byte gridX = (byte)ConsoleTrack.GetArgAsInt();

            ConsoleTrack.possibleTabs = "Example: setLevel 10 10 MyLevelID";

            // If gridX is assigned:
            if (ConsoleTrack.instructionList.Count >= 2)
            {
                byte gridY = (byte)ConsoleTrack.GetArgAsInt();

                // If gridY is assigned:
                if (ConsoleTrack.instructionList.Count >= 3)
                {
                    // Check if this X, Y grid is valid (has a node at it).
                    WEScene         scene  = (WEScene)Systems.scene;
                    WorldZoneFormat zone   = scene.currentZone;
                    byte[]          wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                    // If the location is a valid node, we can attempt to add a level ID.
                    if (NodeData.IsObjectANode(wtData[5], false, false, true))
                    {
                        string coordStr = Coords.MapToInt(gridX, gridY).ToString();
                        string levelId  = ConsoleTrack.GetArg();
                        ConsoleTrack.helpText = "Assign a level ID to the specified node.";

                        if (zone.nodes.ContainsKey(coordStr))
                        {
                            ConsoleTrack.helpText += " Current level ID is: " + zone.nodes[coordStr];
                        }

                        // If the console was activated:
                        if (ConsoleTrack.activate)
                        {
                            zone.nodes[coordStr] = levelId;
                            return;
                        }
                    }

                    // If the location is invalid:
                    else
                    {
                        ConsoleTrack.helpText = "WARNING! There is not a level node at " + gridX.ToString() + ", " + gridY.ToString();
                    }
                }

                // If gridY has not been assigned:
                else
                {
                    ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the Y position.";
                }
            }

            // If gridX has not been assigned:
            else
            {
                ConsoleTrack.helpText = "Assign a level ID to a node at the specified X, Y coordinate. Enter the X position.";
            }
        }
Beispiel #11
0
        public override void ActivateWorldFuncButton()
        {
            WEScene scene = (WEScene)Systems.scene;

            if (scene.campaign.zoneId > 0)
            {
                scene.SwitchZone((byte)(scene.campaign.zoneId - 1));
            }
        }
Beispiel #12
0
        public override void ActivateWorldFuncButton()
        {
            WEScene scene = (WEScene)Systems.scene;

            if (scene.campaign.zoneId < 8)
            {
                scene.SwapZoneOrder();
                GameValues.LastAction = "WESwapButton";
            }
        }
Beispiel #13
0
        public override void RunTick(WEScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left or Right Mouse Click
            if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked || Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile((byte)Cursor.MiniGridX, (byte)Cursor.MiniGridY);
            }
        }
Beispiel #14
0
        public override void ActivateWorldFuncButton()
        {
            WEScene scene = (WEScene)Systems.scene;

            Systems.handler.worldContent.SaveWorld();
            GameValues.LastAction = "WEPlayButton";

            if (scene.tutorial.tutorialStep == TutorialWorldEdit.finalStep)
            {
                UIHandler.AddNotification(UIAlertType.Warning, "Playtest Fixes", "If something goes wrong, don't worry. Return to map editing or reset your position through the tilde (~) console.", 1500);
            }

            SceneTransition.ToWorld(scene.worldContent.worldId);
        }
Beispiel #15
0
        public override void RunTick(WEScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left Mouse Button
            if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked)
            {
                WorldZoneFormat zone  = scene.currentZone;
                byte            gridX = (byte)Cursor.MiniGridX;
                byte            gridY = (byte)Cursor.MiniGridY;

                byte[] wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                // If the wand clicked on a warp, then we can attempt to assign a warp link ID.
                if (NodeData.IsObjectAWarp(wtData[5]))
                {
                    UIHandler.SetMenu(UIHandler.worldEditConsole, true);
                    UIHandler.worldEditConsole.Open();
                    UIHandler.worldEditConsole.SendCommand("setWarp " + gridX.ToString() + " " + gridY.ToString() + " ", false);
                    ChatConsole.SendMessage("--------------------", Color.White);
                    ChatConsole.SendMessage("Assign a Link ID to this Warp Node. Must be a number between 1 and 20. Warps that share the same ID will link to each other. ", Color.Red);
                    ChatConsole.SendMessage("--------------------", Color.White);
                    ChatConsole.SendMessage("Example: setWarp " + gridX.ToString() + " " + gridY.ToString() + " 1", Color.Green);
                    ChatConsole.SendMessage("--------------------", Color.White);
                }

                // If the wand clicked on a node, then we can attempt to assign a level.
                if (NodeData.IsObjectANode(wtData[5], false, false, true))
                {
                    UIHandler.SetMenu(UIHandler.worldEditConsole, true);
                    UIHandler.worldEditConsole.Open();
                    UIHandler.worldEditConsole.SendCommand("setLevel " + gridX.ToString() + " " + gridY.ToString() + " ", false);
                    ChatConsole.SendMessage("--------------------", Color.White);
                    ChatConsole.SendMessage("Assign a Level ID to this Node. It can be any valid level, including official levels or levels created by other players. The original author will be credited with the level design.", Color.Red);
                    ChatConsole.SendMessage("--------------------", Color.White);
                    ChatConsole.SendMessage("Example: setLevel " + gridX.ToString() + " " + gridY.ToString() + " TUTORIAL_1", Color.Green);
                    ChatConsole.SendMessage("--------------------", Color.White);
                }
            }

            // Right Mouse Button (Clone Current Tile)
            else if (Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile((byte)Cursor.MiniGridX, (byte)Cursor.MiniGridY);
            }
        }
Beispiel #16
0
        public static void ResizeMap()
        {
            string currentIns = ConsoleTrack.GetArgAsString();
            int    curVal     = ConsoleTrack.GetArgAsInt();

            ConsoleTrack.PrepareTabLookup(resizeOpts, currentIns, "Resize World Map");

            // Width Option
            if (currentIns == "width")
            {
                int currentWidth = ((WEScene)Systems.scene).xCount;
                ConsoleTrack.possibleTabs = "Example: resize width 60";
                ConsoleTrack.helpText     = "Choose a width between " + (byte)WorldmapEnum.MinWidth + " and " + (byte)WorldmapEnum.MaxWidth + ". Currently at " + currentWidth + ".";
            }

            // Height Option
            else if (currentIns == "height")
            {
                int currentHeight = ((WEScene)Systems.scene).yCount;
                ConsoleTrack.possibleTabs = "Example: resize height 60";
                ConsoleTrack.helpText     = "Choose a height between " + (byte)WorldmapEnum.MinHeight + " and " + (byte)WorldmapEnum.MaxHeight + ". Currently at " + currentHeight + ".";
            }

            else
            {
                return;
            }

            // Activate Resize
            if (ConsoleTrack.activate && curVal > 0)
            {
                WEScene scene = (WEScene)Systems.scene;

                if (currentIns == "width" && curVal >= (byte)WorldmapEnum.MinWidth && curVal <= (byte)WorldmapEnum.MaxWidth)
                {
                    scene.ResizeWidth((byte)curVal);
                }

                else if (currentIns == "height" && curVal >= (byte)WorldmapEnum.MinHeight && curVal <= (byte)WorldmapEnum.MaxHeight)
                {
                    scene.ResizeHeight((byte)curVal);
                }

                else
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Resize", "Resize must be within the allowed range.", 240);
                }
            }
        }
Beispiel #17
0
        public static void SetMusicTrack()
        {
            string  currentIns = ConsoleTrack.GetArgAsString();
            WEScene scene      = (WEScene)Systems.scene;

            // Update the tab lookup.
            ConsoleTrack.PrepareTabLookup(ConsoleEditData.TrackCategory, currentIns, "Choose a music category for the track to play.");

            if (!ConsoleEditData.TrackCategory.ContainsKey(currentIns))
            {
                return;
            }

            // Remove Music From Level
            if (currentIns == "none")
            {
                scene.worldContent.data.music = 0;
                UIHandler.AddNotification(UIAlertType.Warning, "Removed Music Track", "World currently has no music assigned.", 240);
                return;
            }

            Dictionary <string, object> trackCat = ConsoleEditData.TrackLookup[currentIns];

            string trackName = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(trackCat, trackName, "Set a music track for the world.");

            if (MusicAssets.TrackNames.ContainsKey(scene.worldContent.data.music))
            {
                ConsoleTrack.helpText += "Currently: \"" + MusicAssets.TrackNames[scene.worldContent.data.music].Replace("Music/", "") + "\".";
            }

            // Activate the Instruction
            if (ConsoleTrack.activate)
            {
                if (trackCat.ContainsKey(trackName))
                {
                    byte track = (byte)trackCat[trackName];
                    scene.worldContent.data.music = (byte)track;
                    UIHandler.AddNotification(UIAlertType.Success, "Set Music Track", "Music Track set to " + MusicAssets.TrackNames[track].Replace("Music/", "") + ".", 240);
                    return;
                }

                // Prevent Rename if it exceeds name length.
                UIHandler.AddNotification(UIAlertType.Error, "Invalid Music Track", "Designated music track doesn't exist.", 240);
            }
        }
Beispiel #18
0
        public static void SetLives()
        {
            short   lives = (short)ConsoleTrack.GetArgAsInt();
            WEScene scene = (WEScene)Systems.scene;

            ConsoleTrack.possibleTabs = "Example: `lives 50`";
            ConsoleTrack.helpText     = "Set the number of lives you start with: 1 to 500. Currently: " + scene.worldData.lives;

            if (ConsoleTrack.activate)
            {
                if (lives < 1 || lives > 500)
                {
                    UIHandler.AddNotification(UIAlertType.Error, "Invalid Lives", "Lives must be set between 1 and 500.", 240);
                    return;
                }

                scene.worldContent.data.lives = lives;
                UIHandler.AddNotification(UIAlertType.Success, "Lives Set", "World campaign assigned to have \"" + lives + "\" lives.", 240);
            }
        }
Beispiel #19
0
        public static void SetMode()
        {
            string currentIns = ConsoleTrack.GetArgAsString();

            ConsoleTrack.PrepareTabLookup(modeOpts, currentIns, "Set the campaign mode for this world.");

            // If an option is selected:
            if (modeOpts.ContainsKey(currentIns))
            {
                ConsoleTrack.helpText     = modeOpts[currentIns].ToString();
                ConsoleTrack.possibleTabs = "";
            }

            if (ConsoleTrack.activate)
            {
                WEScene scene = (WEScene)Systems.scene;
                UIHandler.AddNotification(UIAlertType.Warning, "Unavailable - Alpha", "These game modes cannot be set during the alpha release.", 300);
                return;
            }
        }
Beispiel #20
0
        public override void RunTick(WEScene scene)
        {
            if (UIComponent.ComponentWithFocus != null)
            {
                return;
            }

            // Left Mouse Button Down (Delete Current Tile)
            if (Cursor.mouseState.LeftButton == ButtonState.Pressed)
            {
                WorldZoneFormat zone  = scene.currentZone;
                byte            gridX = (byte)Cursor.MiniGridX;
                byte            gridY = (byte)Cursor.MiniGridY;

                byte[] wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                // Delete Tile Top if the base is not water.
                if (wtData[0] != (byte)OTerrain.Water)
                {
                    scene.worldContent.DeleteTileTop(zone, gridX, gridY);
                }

                // Delete Tile Cover
                scene.worldContent.DeleteTileCover(zone, gridX, gridY);

                // Handle Special Deletes for Nodes
                if (scene.DeleteNodeIfPresent(gridX, gridY))
                {
                    return;
                }

                // Delete Objects (unless node was already deleted)
                scene.worldContent.DeleteTileObject(zone, gridX, gridY);
            }

            // Right Mouse Button Clicked (Clone Current Tile)
            else if (Cursor.RightMouseState == Cursor.MouseDownState.Clicked)
            {
                scene.CloneTile((byte)Cursor.MiniGridX, (byte)Cursor.MiniGridY);
            }
        }
Beispiel #21
0
        public static byte curWESlotGroup;         // Tracks which wheel menu is currently selected (relevant for the Utility Bar).

        public WE_UI(WEScene scene)
        {
            this.scene = scene;
            this.atlas = Systems.mapper.atlas[(byte)AtlasGroup.World];

            // UI Components
            this.gridUI     = new GridOverlay(null, (byte)WorldmapEnum.TileWidth, (byte)WorldmapEnum.TileHeight);
            this.utilityBar = new WEUtilityBar(null, this.scene, (byte)WorldmapEnum.TileWidth, (short)(Systems.screen.viewHeight - (byte)WorldmapEnum.TileHeight));
            this.scroller   = new WEScroller(null, this.scene, (short)(Systems.screen.viewWidth - (byte)WorldmapEnum.TileWidth), 0);
            this.statusText = new UIStatusText(null, (short)Systems.screen.viewHalfWidth, 5);

            // Tab Menu - WorldTileTool Listings
            this.weMenu = new WEMenu(null, (short)(Systems.screen.viewWidth * 0.5f), (short)(Systems.screen.viewHeight * 0.5f), 4, 2);

            this.weMenu.SetMenuOption((byte)1, Systems.mapper.atlas[(byte)AtlasGroup.World], "Mud/b1", "Terrain");
            this.weMenu.SetMenuOption((byte)2, Systems.mapper.atlas[(byte)AtlasGroup.World], "Desert/p7", "Detail");
            this.weMenu.SetMenuOption((byte)3, Systems.mapper.atlas[(byte)AtlasGroup.World], "MountainBrown/s", "Coverage");
            this.weMenu.SetMenuOption((byte)4, Systems.mapper.atlas[(byte)AtlasGroup.World], "Objects/Pyramid1", "Objects");
            this.weMenu.SetMenuOption((byte)5, Systems.mapper.atlas[(byte)AtlasGroup.World], "Objects/NodeStrict", "Nodes");
            this.weMenu.SetMenuOption((byte)6, UIHandler.atlas, "Move", "Resize");
        }
Beispiel #22
0
        public static void SetWarp()
        {
            byte gridX = (byte)ConsoleTrack.GetArgAsInt();

            ConsoleTrack.possibleTabs = "Example: setWarp 10 10 1";

            // If gridX is assigned:
            if (ConsoleTrack.instructionList.Count >= 2)
            {
                byte gridY = (byte)ConsoleTrack.GetArgAsInt();

                // If gridY is assigned:
                if (ConsoleTrack.instructionList.Count >= 3)
                {
                    // Check if this X, Y grid is a valid warp.
                    WEScene         scene  = (WEScene)Systems.scene;
                    WorldZoneFormat zone   = scene.currentZone;
                    byte[]          wtData = scene.worldContent.GetWorldTileData(zone, gridX, gridY);

                    // If the location is a valid node, we can attempt to add a level ID.
                    if (NodeData.IsObjectAWarp(wtData[5]))
                    {
                        string coordStr = Coords.MapToInt(gridX, gridY).ToString();
                        byte   linkID   = (byte)ConsoleTrack.GetArgAsInt();
                        ConsoleTrack.helpText = "Assign a warp link ID (1-20). Teleports to a warp with the same warp link ID.";

                        if (zone.nodes.ContainsKey(coordStr))
                        {
                            byte getLinkId;
                            byte.TryParse(zone.nodes[coordStr].Replace("_warp", ""), out getLinkId);
                            ConsoleTrack.helpText += " Currently: " + getLinkId;
                        }

                        // If the console was activated:
                        if (ConsoleTrack.activate)
                        {
                            // Error if the values aren't allowed:
                            if (linkID < 1 || linkID > 20)
                            {
                                UIHandler.AddNotification(UIAlertType.Error, "Invalid Warp Link", "Warp Link ID must be set between 1 and 20.", 240);
                                return;
                            }

                            UIHandler.AddNotification(UIAlertType.Success, "Warp Set", "Warp Link ID assigned as " + linkID.ToString() + ".", 240);
                            zone.nodes[coordStr] = "_warp" + linkID.ToString();
                            return;
                        }
                    }

                    // If the location is invalid:
                    else
                    {
                        ConsoleTrack.helpText = "WARNING! There is not a warp at " + gridX.ToString() + ", " + gridY.ToString();
                    }
                }

                // If gridY has not been assigned:
                else
                {
                    ConsoleTrack.helpText = "Assign a link ID to a warp at the specified X, Y coordinate. Enter the Y position.";
                }
            }

            // If gridX has not been assigned:
            else
            {
                ConsoleTrack.helpText = "Assign a link ID to a warp at the specified X, Y coordinate. Enter the X position.";
            }
        }