Author Topic: Ingame Map Settings Page  (Read 3898 times)

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Ingame Map Settings Page
« on: September 10, 2017, 07:40:19 pm »
Here's code to allow modders to have settings for their maps that can be changed in game. I've also added a couple extra things (total number of planets and number of golems) for  fun.  As a heads up, you will need to change the map type once in order to get the settings to appear (see the in-code comments, not sure how to handle it).

For modders, to add support for your own settings:

  • Add the setting itself in the Settings XML code
  • Add the name of that setting to the  getSettingNamesForMap function in Window_GameSetup.cs
  • Use the functions in MapGenerationBadger.cs to get the value for the setting, then actually use that value in the map generation code

One request is for an IntDropdownHidden for settings where there are a discrete number of choices that aren't readily identified by a number (for example, I want to let the player choose the linking algorithm for a map. An evocative name "Constellation" or a descriptive name "Spanning Tree" is much better than just the number 2).


Here are a couple pictures and the code. You should just be able to extract the tarball into your directory tree and have things go to the right places.

Offline keith.lamothe

  • Arcen Games Staff
  • Arcen Staff
  • Zenith Council Member Mark III
  • *****
  • Posts: 19,505
Re: Ingame Map Settings Page
« Reply #1 on: September 10, 2017, 09:11:28 pm »
Awesome, thank you :)

On the IntDropdownHidden, that's a bit of a misnomer in that the names in the setting types that include Dropdown, Textbox, etc are saying what type of control the settings menu should use for them. You can use whatever control you like in other settings. Hidden just tells it "don't put this on the setting menu, I'll handle exposing it to the user (or not) myself".

Is there something preventing you from setting up an enum (or other int-mapped type) and a dropdown?
Have ideas or bug reports for one of our games? Mantis for Suggestions and Bug Reports. Thanks for helping to make our games better!

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Ingame Map Settings Page
« Reply #2 on: September 10, 2017, 09:33:57 pm »
Having some IntHiddens appear as dropdowns would be quite possible. However, that would involve the Window_GameSetup.cs code saying "Is your variable named X? Ah, it's a dropdown, handle this differently". I don't really like things that look identical from the outside (ie the xml) but work very differently on the inside. I feel like it's poor coding practice and apt to confuse some other poor sucker who comes along, which is why I didn't do it that way.

That said, there's nothing stopping me from doing it that way except my sense of taste. And there are a million things in AI War 2 development that are more important than appeasing my sense of taste, so feel free to tell me to just make it work ;-)

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Ingame Map Settings Page
« Reply #3 on: September 10, 2017, 10:20:54 pm »
Oh, I might have forgotten to include the code to load the current values into temp. I'd stuck it in Window_MainMenu.cs

        public class bStartGame : ButtonAbstractBase
        {
            public override void GetTextToShow( ArcenDoubleCharacterBuffer Buffer )
            {
                base.GetTextToShow( Buffer );
                Buffer.Add( "Start New Game" );
            }
            public override MouseHandlingResult HandleClick() {
              ArcenSettingTable.Instance.CopyCurrentValuesToTemp(); <===
              Input_MainHandler.HandleInner( 0, "DebugGenerateMap" );
                return MouseHandlingResult.None;
            }
            public override void HandleMouseover() { }
            public override void OnUpdate() { }
        }



Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Ingame Map Settings Page
« Reply #4 on: September 14, 2017, 01:06:39 pm »
I have now implemented some dropdown menus where appropriate. Tooltips and dropdowns don't seem to play very nicely together, but overall it works.

I'll post the code and some new screenshots when I get home.

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Ingame Map Settings Page
« Reply #5 on: September 14, 2017, 11:55:48 pm »
Okay, I've added proper dropdowns! I've added a Conduct so you can toggle whether you want to see the map settings (otherwise they can kinda crowd out the map depending on your UI settings). Here are some pics and the code. Opinions?

Tadrinth, I also changed some of the settings for the Octopus because it looked really crowded and the planets seemed very close together. I hope that's okay.

Offline BadgerBadger

  • Arcen Volunteer
  • Hero Member Mark III
  • *****
  • Posts: 1,229
  • BadgerBadgerBadgerBadger
Re: Ingame Map Settings Page
« Reply #6 on: September 28, 2017, 11:04:06 pm »
Okay, so I reworked things a bit. Instead of giving direct controls for things like "How many planets per cluster" I now provide just settings like "Number of Clusters: Low/Medium/High". This makes it much easier to work with. Here's a picture and some code.

Keith, I note that when you first click "Start New Game", Window_GameSetup.Instance.currentMapType is null (it only gets set on dMapType::HandleSelectionChanges(). I'm not sure how to check the Current Map Type for the very first map type that's visible when you enter the window.

I don't have any additional clever ideas for things to do with this code. I do believe that the "Number of Planets" needs to be handled in Arcen code since that value should be passed into Generate(), and you probably want to remove the "Select number of Golems" but those are super easy to tweak as you deem appropriate. Otherwise as far as I'm concerned this is all good for prime time. As always, I'm happy to take feedback, but I have no current plans to change anything until I get some bug reports or change requests.
« Last Edit: September 30, 2017, 06:18:32 pm by BadgerBadger »