Jump to content
The Dark Mod Forums

Recommended Posts

Posted
On 9/1/2024 at 1:57 PM, stgatilov said:

If you look into mainmenu_custom_defs.gui, you'll see that the current suggested approach for main menu in campaigns is using #if MM_CURRENTMISSION == 2. So you can set defines for separate single missions first, then put them all in a single file and wrap in #if-s.

I didn't know this. Is this page still up to date: https://wiki.thedarkmod.com/index.php?title=Setting_up_Campaigns ? 

Because it looks like it does things like:

if ("gui::CurrentMission" == 1)
		{
			set "BriefingMission1Animation::visible" "1";
			resetTime "BriefingMission1Animation" 0;
		}
		else if ("gui::CurrentMission" == 2)
		{
			set "BriefingMission2Animation::visible" "1";
			resetTime "BriefingMission2Animation" 0;

But then inside the text briefing. 

So would you instead use if MM_CURRENTMISSION == # instead like:

if MM_CURRENTMISSION == 1
		
		set "BriefingMission1Animation::visible" "1";
		resetTime "BriefingMission1Animation" 0;
		
    else if MM_CURRENTMISSION == 2
		
		set "BriefingMission2Animation::visible" "1";
		resetTime "BriefingMission2Animation" 0;

 

Or am I just confusing things?

 

Quote

So you can set defines for separate single missions first, then put them all in a single file and wrap in #if-s.

I don't actually understand what you mean with this.

Posted
4 hours ago, datiswous said:

I didn't know this. Is this page still up to date: https://wiki.thedarkmod.com/index.php?title=Setting_up_Campaigns ? 

No, it is not up-to-date.

You can use gui::CurrentMission, but it is not flexible enough.
You need to set defines to enable/disable mission stages, like briefing or briefing video. You can't enabled defines depending on GUI variable, you can only enable them depending on define like MM_CURRENTMISSION.

I'd suggest the following way to set up campaign:

  1. Forget about campaign and concentrate on the first mission.
  2. Set up the first mission as you normally do.
  3. Save the customized files somewhere.
  4. Set up the second mission as you normally do.
  5. Save the files somewhere.
  6. Set up the third mission.
  7. Now look at all the differences in GUI code between three variants, and wrap them into #ifdef-s by MM_CURRENTMISSION however is more comfortable for you.

For instance, if you need to separately enable/disable stages or change menu backgrounds, you can make 3 sections in mainmenu_custom_defs.gui inside #ifdef-s.

If you want to play different briefing video, you can do #ifdef around MM_BRIEFING_VIDEO_MATERIAL_1 and set it to different stuff depending on the define.

If you want to make GUI briefings with custom GUI code, you can put them into mainmenu_briefing_1.gui, mainmenu_briefing_2.gui, mainmenu_briefing_3.gui, then include one of these files based on MM_CURRENTMISSION inside mainmenu_briefing.gui.
 

Of course you can avoid this copying around and keeping 3 versions if you understand how it works and how you plan to manage it.

  • Like 1
  • Thanks 1
Posted
On 7/25/2025 at 3:39 PM, datiswous said:

I was just thinking, you could make a campaign but in the first mission briefing, you could give the option to play any mission in the campaign seperate instead. Not sure if this would generate problems, because the missions are originally set up as a campaign.

I guess you'll have problem because the number of missions in campaign is still read from tdm_mapsequence.txt.
Either you set 1 mission there and the second one won't start, or you set 3 missions there and player will get into briefing sequence again after the first mission ends.

  • Like 1
Posted (edited)
4 hours ago, stgatilov said:

I'd suggest the following way to set up campaign:

  1. Forget about campaign and concentrate on the first mission.
  2. Set up the first mission as you normally do.
  3. Save the customized files somewhere.
  4. Set up the second mission as you normally do.
  5. Save the files somewhere.
  6. Set up the third mission.
  7. Now look at all the differences in GUI code between three variants, and wrap them into #ifdef-s by MM_CURRENTMISSION however is more comfortable for you.

Hmm, that sounds a lot easier. 

Well if I understand it better in the future I might write some text about it on the wiki. Pretty bad to have outdated info on this.

Edited by datiswous
  • Thanks 1
Posted
On 11/26/2025 at 8:59 PM, stgatilov said:

If you want to make GUI briefings with custom GUI code, you can put them into mainmenu_briefing_1.gui, mainmenu_briefing_2.gui, mainmenu_briefing_3.gui, then include one of these files based on MM_CURRENTMISSION inside mainmenu_briefing.gui.

What code do you use to reference which gui files to use per MM_CURRENTMISSION ? I cannot find this info in mainmenu_briefing_1.gui .

Posted
25 minutes ago, datiswous said:

What code do you use to reference which gui files to use per MM_CURRENTMISSION ? I cannot find this info in mainmenu_briefing_1.gui .

No, this code you are supposed to write yourself.
Just put the following inside mainmenu_briefing.gui:

#if MM_CURRENTMISSION == 1
  #include "mainmenu_briefing_preamble.gui"
#elif MM_CURRENTMISSION == 2
  #include "mainmenu_briefing_riddle.gui"
#elif MM_CURRENTMISSION == 3
  #include "mainmenu_briefing_final.gui"
#endif

 

  • Thanks 1
Posted
11 hours ago, stgatilov said:

No, this code you are supposed to write yourself.
Just put the following inside mainmenu_briefing.gui:

#if MM_CURRENTMISSION == 1
  #include "mainmenu_briefing_preamble.gui"
#elif MM_CURRENTMISSION == 2
  #include "mainmenu_briefing_riddle.gui"
#elif MM_CURRENTMISSION == 3
  #include "mainmenu_briefing_final.gui"
#endif

 

So can you just use a mainmenu_briefing.gui file with only above code and have these seperate files that have the full gui code in them for the specific briefings for each mission?

Sorry it's just a bit difficult for me to wrap my head around it.

 

Is there an example of a campaign using advanced gui?

 

I'm writing this draft for updated campaign documentation:

https://wiki.thedarkmod.com/index.php?title=User:Datiswous

Posted
6 hours ago, datiswous said:

So can you just use a mainmenu_briefing.gui file with only above code and have these seperate files that have the full gui code in them for the specific briefings for each mission?

Yes, you can just set up #ifdef + #include in mainmenu_briefing.gui and store everything separately in separate files.

Quote

Sorry it's just a bit difficult for me to wrap my head around it.

Well, as long as you know how to use C preprocessor, you can find whatever workflow looks more convenient to you. The file mainmenu_briefing.gui is controlled by the mapper.

Quote

Is there an example of a campaign using advanced gui?

There is campaign sample I posted above, but GUI briefing there is still made the old way, I did not touch it.
I feel that the workflow with #ifdef-s might lead to more convenient workflow, but I guess nobody tried.
You know, there were not that many campaigns out there when I did all that, I guess every campaign being created is big enough event to just torture all the information out of me 🤣 or ask me to merge separate mission GUIs into campains.

Posted (edited)
3 hours ago, stgatilov said:

Yes, you can just set up #ifdef + #include in mainmenu_briefing.gui and store everything separately in separate files.

This doesn't work. I get a black screen with a cursor and in the console I get an error stating it cannot find the file referenced in the first #include, although the file is present with that name in that location.

I think maybe it's only possible to #include a gui from an external file if the file where you place the include already has some gui code?

Edited by datiswous
Posted

What is the difference of using:

#if MM_CURRENTMISSION == 1
	#include "mainmenu_briefing_preamble.gui"

instead of:

if ("gui::CurrentMission" == 1)
	#include "mainmenu_briefing_preamble.gui"

?

 

So what I think how you're supposed to do it:

1. You make a mission with a specific briefing gui

2. You make another mission with a specific briefing gui

3. Afterwards you place #if MM_CURRENTMISSION == 1 over sections that are specific for mission 1 and similar in the file of mission 2 , but by using #if MM_CURRENTMISSION == 2 instead. Then you name the file for mission 1 "mainmenu_briefing.gui" and at the end #include the file for mission 2.

Posted
2 hours ago, datiswous said:

I get a black screen with a cursor and in the console I get an error stating it cannot find the file referenced in the first #include, although the file is present with that name in that location.

Sorry, I think it should be #include "guis/mainmenu_briefing_preamble.gui"
At least that's what I see in some existing gui files: the guis subdirectory is important.

Quote

I think maybe it's only possible to #include a gui from an external file if the file where you place the include already has some gui code?

I think it is irrelevant.

1 hour ago, datiswous said:

What is the difference of using:

#if MM_CURRENTMISSION == 1
	#include "mainmenu_briefing_preamble.gui"

instead of:

if ("gui::CurrentMission" == 1)
	#include "mainmenu_briefing_preamble.gui"

Just like in C/C++, C preprocessor runs before the main language and does simple textual transforms only. It does not know the main language at all. It understands only directives (lines starting from #) and some strings which were #define-d beforehand. After preprocessor is over, the main language starts working, and it only sees what is produced by preprocessor, it has no way to know about the directives.

So in the first example it will check if the current mission is indeed 1. If it is not, it will remove the section inside #if from the source code, the Doom 3 GUI language will not even know it was there. If it is, then the section will survive. Then it will handle the #include, which basically says "please copy/paste the contents of that file here".

In the second example, the preprocessor has no freaking idea what the first line means. It is not a directive. So it will leave it as is, regardless of which mission it runs now. The it will handle the #include, i.e. copy/paste the file contents regardless of which mission is now.

Given that Doom 3 GUi language only allows to use if-s inside event handlers, the second approach is only valid if you use it inside a single script event handler. Which is often too small.

Quote

So what I think how you're supposed to do it:

1. You make a mission with a specific briefing gui

2. You make another mission with a specific briefing gui

3. Afterwards you place #if MM_CURRENTMISSION == 1 over sections that are specific for mission 1 and similar in the file of mission 2 , but by using #if MM_CURRENTMISSION == 2 instead. Then you name the file for mission 1 "mainmenu_briefing.gui" and at the end #include the file for mission 2.

But then the parts which are not specific to either mission will be included/present twice, no?

In fact, if #include sounds complicated to you, you can just do everything without it.
Imagine that file2.gui contains the full GUI code for mission 1, and file2.gui contains the full GUI code for mission 2.
Just put contents of both files into mainmenu_briefing.gui surrounded by appropriate #if MM_CURRENTMISSION == ? and #endif. Preprocessor will process each #if and drop the ones which are false.

Since #include is just a command for preprocessor to copy/paste, it works effectively the same way. It just allows you to have one mission per file instead of one megafile with the stuff for all missions (well, as long as paths are correct).

  • Like 1
Posted
22 hours ago, stgatilov said:

Sorry, I think it should be #include "guis/mainmenu_briefing_preamble.gui"
At least that's what I see in some existing gui files: the guis subdirectory is important.

Thanks. It works now!

I actually converted your tdm_campaign_sample to use the new campaign system, but there's one bug present and that is that if you finish the mission and you start it again, you still see the gui of mission 3. This shouldn't be possible since it should load mainmenu_briefing.gui file with this in it:

#if MM_CURRENTMISSION == 1
    #include "guis/m1.gui"
#elif MM_CURRENTMISSION == 2
    #include "guis/m2.gui"
#elif MM_CURRENTMISSION == 3
    #include "guis/m3.gui"
#endif

It does load the objectives/difficulty screen after it correctly.

The original version does not do this. No clue why this is, but ok.

guis_tdm_c_s.zip

  • Like 1
Posted
14 hours ago, datiswous said:

I actually converted your tdm_campaign_sample to use the new campaign system, but there's one bug present and that is that if you finish the mission and you start it again, you still see the gui of mission 3.

I think the problem here is that when you finish the whole campaign, there is no reset of MM_CURRENTMISSION back to 1.

UPDATE: Fixed in svn rev 11030, I hope.

  • Thanks 1
Posted

@stgatilov can you check out the draft I made and see if some of it needs changes? I used some of the text in your posts.

The example section about video I probably have to move to the video section below, which also seems outdated..

Here is the draft: wiki.thedarkmod.com/index.php?title=User:Datiswous

Here is the original wiki page that I'm trying to update: wiki.thedarkmod.com/index.php?title=Setting_up_Campaigns

  • Like 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recent Status Updates

    • datiswous

      (I just write this down, because it's on my mind)
      I think it's time somebody makes the city hub fm 😉
      Technically I see 2 possible ways.
      1. One is where everything takes place inside one mission and you teleport to different enclosed areas of the map to do subquests.
      2. Another is a campaign style mission. You start inside the cityhub. When you do a subquest, the mission ends, but the next mission you load the specific quest-map. This questmap you load is depended on what subquest you choose to start inside the map. Afterwards you load the 3th mission in the campaign which will be the cityhub map again, but via persistant info, changes some things inside the map (for example, you can't do the same subquest twice) and you have more gold maybe, etc, etc. So if the cityhub has 5 subquest missions that can be played in any order, the total amount of missions in the campaign would be 10, but the amount of map files 6. Because if you start in the cityhub map, after each subquest mission, you return to the cityhub map again, except for the last mission. When you make missions later you can add them to the cityhub again and make it bigger.
      (This seems all possible with changes made in TDM 2.13 , but I'm not 100% sure. It's at least an interesting project to work on)
      · 0 replies
    • datiswous

      I started using Unexpected Keyboard for Android phone.
      It's pretty cool, because it has an actual Ctrl key, which you can use to do cut, copy and paste actions via x, c and v. pretty handy in the forums, to move quoted text around for example.
      · 0 replies
    • STiFU

      New home, who dis? 🙂
      · 3 replies
    • Xolvix

      Dammit there are too many missions available now. That's what I get for being away for so long. Such a first-world problem.
      · 1 reply
    • DeTeEff

      The best thing about not mapping more than like every other year is the awesome feeling to see how far TDM has gotten in all appartments. I can just create some parallaxing cobblestones and walk to and fro and just let the jaw drop
      · 2 replies
×
×
  • Create New...