tModLoader WorldGen Previewer

jopojelly

Retinazer
tModLoader
e3QKzY4.png

WorldGen Previewer
Latest Download:
Mod Browser (in-game) - Direct link - Alt download link

Open to collaboration on GitHub
Discord:

This mod changes the world generation screen to include a preview of the map as it generates. You can also pause/resume generation as you like.

Please let me know problems you run into.

Performance: For me it added 1 second to a small world, but I have a new computer, let me know how it works for you.

Videos of mod in action:

Watch World Generation happen before your EYES!

Pause World Generation and look around!

Repeat steps for fun!

Don't like what you see? Cancel that world!
Planned features:
  • Reset Button maybe?
  • Any Suggestions?
Issues:
  • None that I know of.
Changelog:

v0.2
  • Cancel button now actually works. (no more corrupting subsequent worldgen)
  • Scan line visualizer
v0.1.3.3
  • Cancel button.
v0.1.3.1
  • Updated to tModLoader v0.9.0.0
v0.1.3
  • Next Button -- Generates next step and then pauses.
  • Repeat Previous Button -- Repeat a step, great for crazy things.
  • Show Generation Steps Button -- See list of upcoming steps.
  • Nicer UI
v0.1
  • Initial Release
  • Pause/Resume world gen
  • See Map of world as it is generating

WorldGenPreviewer.png
 
Last edited:
WorldGen Previewer
Latest Download: Mod Browser or direct link
This mod changes the world generation screen to include a preview of the map as it generates. You can also pause/resume generation as you like.

Please let me know problems you run into.

Performance: For me it added 1 second to a small world, but I have a new computer, let me know how it works for you.

Videos of mod in action:

Watch World Generation happen before your EYES!

Pause World Generation and look around!

Changelog

v0.1
  • Initial Release
  • Pause/Resume world gen
  • See Map of world as it is generating
This looks awesome but if there is one feature I would like to see is the ability to completely stop world generation after a certain point and be able to use the world partially generated.
 
Looks fantastic. Thank you once again for all your incredibly useful mods that I can no longer live without. :)


Can I ask why you'd want such a feature? Other than purely for testing purposes involving new biome spawns etc, I'd imagine doing this could really screw up the game.
Testing features in a mod I am working on without dealing with all the complexity of the Terrain but still having a simple world
 
If you have this installed, will it do the same for TerraCustom? (i.e. will TerraCustom detect this and therefore show the same ui to this?)
Yes, I tried it and it showed up in TerraCustom as normal. I may integrate it naturally in TerraCustom eventually, but either way, it works.

Testing features in a mod I am working on without dealing with all the complexity of the Terrain but still having a simple world
When I was testing some world gen code, I removed a few ranges from the task list using the ModifyWorldGen hook so I could generate basic worlds in a few seconds, you could try that. Also, I would also make items that would run the world gen code at the mouse cursor so I could test world gen code that way too.
 
WorldGen Previewer
Latest Download: Mod Browser or direct link
This mod changes the world generation screen to include a preview of the map as it generates. You can also pause/resume generation as you like.

Please let me know problems you run into.

Performance: For me it added 1 second to a small world, but I have a new computer, let me know how it works for you.

Videos of mod in action:

Watch World Generation happen before your EYES!

Pause World Generation and look around!

Changelog

v0.1
  • Initial Release
  • Pause/Resume world gen
  • See Map of world as it is generating
Very cool mod!
 
BTW, the mod is open source on GitHub: https://github.com/JavidPack/WorldGenPreviewer

The code isn't too applicable to other uses in modding, but maybe the reflection bits can be a good example to someone.

If you are looking for a more normal example of UI within worldgen, maybe to give your user an option or something, below is a code example:

Code:
using Terraria.ModLoader;
using Terraria;
using Terraria.GameContent.Generation;
using System.Collections.Generic;
using Terraria.World.Generation;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.GameContent.UI.Elements;
using Terraria.UI;

namespace SkyDiveExperiment
{
    public class SkyDiveExperiment : Mod
    {
        public SkyDiveExperiment()
        {
            Properties = new ModProperties()
            {
                Autoload = true, // We need Autoload to be true so our ModWorld class below will be loaded.
            };
        }
    }

    internal class InterruptModWorld : ModWorld
    {
        internal static bool continueWorldGen = false;
        internal static bool skydive;

        public override void PostWorldGen()
        {
            Main.MenuUI.SetState(new ExampleUI());
            while (true)
            {
                if (continueWorldGen)
                {
                    if (skydive)
                    {
                        Main.spawnTileY = 100; // Do things based on choice
                    }
                    Main.MenuUI.GoBack();
                    continueWorldGen = false; // reset for next world gen
                    break;
                }
            }
        }
    }

    class ExampleUI : UIState
    {
        public UIPanel coinCounterPanel;
        private UIText _buttonLabel;

        public override void OnInitialize()
        {
            coinCounterPanel = new UIPanel();
            coinCounterPanel.SetPadding(0);
            coinCounterPanel.HAlign = .5f;
            coinCounterPanel.VAlign = .5f;
            coinCounterPanel.Width.Set(300f, 0f);
            coinCounterPanel.Height.Set(100f, 0f);
            coinCounterPanel.BackgroundColor = new Color(73, 94, 171);

            UITextPanel text = new UITextPanel("Would you like to go Sky diving?");
            text.HAlign = 0.5f;
            text.Top.Set(5f, 0f);
            coinCounterPanel.Append(text);

            _buttonLabel = new UIText("", 1f, false);
            _buttonLabel.VAlign = .8f;
            _buttonLabel.HAlign = .5f;
            coinCounterPanel.Append(_buttonLabel);

            Texture2D buttonPlayTexture = ModLoader.GetTexture("Terraria/UI/ButtonPlay");
            UIImageButton playButton = new UIImageButton(buttonPlayTexture);
            playButton.Width.Set(22, 0f);
            playButton.Height.Set(22, 0f);
            playButton.VAlign = .8f;
            playButton.HAlign = .25f;
            playButton.OnClick += new MouseEvent(PlayButtonClicked);
            playButton.OnMouseOver += new UIElement.MouseEvent(PlayMouseOver);
            playButton.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
            coinCounterPanel.Append(playButton);

            Texture2D buttonDeleteTexture = ModLoader.GetTexture("Terraria/UI/ButtonDelete");
            UIImageButton closeButton = new UIImageButton(buttonDeleteTexture);
            closeButton.Width.Set(22, 0f);
            closeButton.Height.Set(22, 0f);
            closeButton.VAlign = .8f;
            closeButton.HAlign = .75f;
            closeButton.OnClick += new MouseEvent(CloseButtonClicked);
            closeButton.OnMouseOver += new UIElement.MouseEvent(DeleteMouseOver);
            closeButton.OnMouseOut += new UIElement.MouseEvent(ButtonMouseOut);
            coinCounterPanel.Append(closeButton);

            base.Append(coinCounterPanel);
        }

        private void PlayButtonClicked(UIMouseEvent evt, UIElement listeningElement)
        {
            Main.PlaySound(10, -1, -1, 1);
            InterruptModWorld.skydive = true;
            InterruptModWorld.continueWorldGen = true;
        }

        private void CloseButtonClicked(UIMouseEvent evt, UIElement listeningElement)
        {
            Main.PlaySound(10, -1, -1, 1);
            InterruptModWorld.skydive = false;
            InterruptModWorld.continueWorldGen = true;
        }

        private void PlayMouseOver(UIMouseEvent evt, UIElement listeningElement)
        {
            this._buttonLabel.SetText("YEAH!");
        }

        private void DeleteMouseOver(UIMouseEvent evt, UIElement listeningElement)
        {
            this._buttonLabel.SetText("No way!");
        }

        private void ButtonMouseOut(UIMouseEvent evt, UIElement listeningElement)
        {
            this._buttonLabel.SetText("");
        }
    }
}

It provides an option to "skydive" during worldgen. All that means is you start in the air and die. It isn't useful, but hopefully this code example is simple enough to show how it works.
Video in action:
 
Last edited:
i want it. also, offtopic, but does the gfycat links not work? it shows a box with a play button but u cant actually press it.
Darn....all my gfycats on all my threads aren't working. Hope it is temporary.

How do you know you want it until you actually watch it: Image Link
 
well i watched it, and OMG i want it even MORE now! 3 dungeons! an unimaginably high number of....anything.
Ok, good enough for me.

Update Released -- v0.1.3

New Features:

Next Button -- Generates next step and then pauses.
Repeat Previous Button -- Repeat a step, great for crazy things.
Show Generation Steps Button -- See list of upcoming steps.
Nicer UI

See above video and this video to see in action.

 
Mod browser not working for me currently and the direct link you posted doesnt work for me for some reason. Idk if im :red:ed or something but could you upload the .tmod file and send the link to me, please? That would be much appreciated. Love your work btw.
 
Mod browser not working for me currently and the direct link you posted doesnt work for me for some reason. Idk if im :red:ed or something but could you upload the .tmod file and send the link to me, please? That would be much appreciated. Love your work btw.
Should work now.
 
Back
Top Bottom