Author Topic: [Request] New Mainhall Capabilities  (Read 9309 times)

0 Members and 1 Guest are viewing this topic.

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
[Request] New Mainhall Capabilities
I originally asked CommanderDJ for these requests. He was interested, but doesn't have the time... so I'm posting them again here hoping to find anyone who might be interested in adding such functionality. Original thread is here. (SCP Internal Board)

I honestly think that with these sort of additions, and these sort of mods popping up... modders would be able to completely redefine what the FSO Interface could be used for.

The first feature is a +Door Region addition to the mainhall.tbl, and involves making the actions that each door in a mainhall does definable by the modder as opposed to hardcoded.

Quote
+Door Region: STRING (So, like +Misc Anim Group, this would need one entry per door.. but be optional)
-For mainhall.tbl
-sets the region for the door (options, exit, ready room, etc.)
-Optional
-Could make duplicate doors.. that's up to the tabler to fix!
-allow Lab and Multi to be settings among others
-Goober's Thoughts
---<@Goober5000> the best way to specify a door action would be to indicate an event in the state machine
---<@Goober5000> the game has a state machine
---<@Goober5000> i.e. it has a number of defined states, meaning configurations or modes
---<@Goober5000> gameplay vs. viewing main hall vs. viewing options, etc.
---<@Goober5000> so if you say "clicking on this region will trigger this state" you could make your region to any number of useful things.

OK, so the +Door Region would still need the mask. The 'regions' of the doors are currently hardcoded. The first door in the list is always 'Exit Game', the third door is always 'Ready Room', etc. The mask just tells FSO what door the mouse is currently hovering over. It does this by color index. The masks look like they are black and white, but they are actually black and 6 shades of white... one for each index, aka, one for each door.

What I'm looking for is a way to remove the hardcoded set of what each door does. So the mouse is over index 1 on the mask, which lines up with door 1 in the list which normally leads to Exit Game. I was hoping to get a new flag, +Door Region:, where I could list pretty much anything from FSO's state machine. Obviously, some of those would not make much sense, but others would be awesome (Think Multi, since the need for a separate multi player is removed.) This should also increase the number of doors from 6 to n. (Which is handy for people who make button based mainhalls.) In general, the door listed first should = the door listed first in the mask, 2=2, 3=3, etc. But I'll need to double check that's how the retail ones work. Obviously, retail compatibility should default to the regular 6 doors listed in the proper order.

CommanderDJ's notes:
Quote
My initial look over the code suggests that it's not as simple as just using FSO's state machine since each transition involves a little more than simply changing the game's state (not to mention most of the state machine's values are completely useless in relation to this), but that's a small issue. The main issue that I have with this is that (if I understand it correctly, someone slap me if I don't!) the mainhall mask tells FSO both the position of each door in the mainhall and the what the door does. If we want to shift the information relating to each door's function to mainhall.tbl, I think it'd be good to decouple those two uses of the mainhall mask (obviously maintaining retail compatibility and all that), which is effectively what this +Door Region property will do: if this is present for a particular door, FSO will only use the corresponding mask value to determine the door's position, and get its function from the table instead. Does this make sense? Opinions, criticisms? From my preliminary look at the code this may or may not be a bigger task than it sounds because, well... :v:.

Goober also had some thoughts:
My initial look over the code suggests that it's not as simple as just using FSO's state machine since each transition involves a little more than simply changing the game's state

Make sure you understand what you're looking at.  There is a fair amount of work in actually changing a game's state, but the state machine handles all of that behind the scenes.  All you have to do is initiate the state change, which you can do with something like gameseq_post_event(GS_EVENT_MAIN_MENU).


Quote
The main issue that I have with this is that (if I understand it correctly, someone slap me if I don't!) the mainhall mask tells FSO both the position of each door in the mainhall and the what the door does.

This is true, but not actually a problem.  The postition of the masking square tells where the door is.  The color of the square tells what it does (specifically, the color index in the palette corresponds to a #define of 0, 1, 2, etc.).  So they are already decoupled.

This should also include the ability to have more than 6 doors/buttons as well.

I have some other mainhall related requests, but this one is easily my most preferred.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline ngld

  • Administrator
  • 29
  • Knossos dev
Re: [Request] New Mainhall Capabilities
I've implemented this as follows:
The mainhall.tbl supports two new keys: "+Door region" and "+Door description"
"+Door region" specifies what happens when the user clicks on that door. Currently allowed are Exit, Barracks, Readyroom, Techroom, Options, Campaigns, Load Mission, Quickstart, Skilllevel and Script.

The first six are the default doors. Load Mission is defined in the code (LOAD_MISSION_REGION) but not implemented (it does nothing). You can trigger it by default by pressing "L".
Quickstart immediatly starts a mission by skipping the briefing screens but works only in debug builds. This can be triggered by pressing "G" right now.
Skilllevel increases the pilot's skill.
Script initiates the GS_STATE_SCRIPTING game state and sets "hv.MenuButton" in LUA to the index of the clicked door. This way the script can tell which door the user chose.

"+Door description" specifies a new description.

"+Door region" comes after "+Door pan" and after that comes "+Door description".

The six first "+Door region" and "+Door description" options overwrite the default options. If you want to add more options you have to edit the mainhall mask and add new areas (with new colors). You also have to add the new options to menu.tbl.

Every door has its own line in menu.tbl which normally looks this:
Code: [Select]
"" COLOR_NUM NULL NULL NULL
You can also write a single letter behind COLOR_NUM to connect that door with a key. COLOR_NUM is a number between 0 and 255. To get the actual color for the mask you have to substract COLOR_NUM from 255 and write the result in hexadecimal.

I.e., if COLOR_NUM is 6:
255 - 6 = 249 = 0xf9
In this case the color is #F9F9F9 (since the mask is greyscale).

Right now the code contains a limit of 20 entries for menu.tbl (in the MAIN HALL section). If you add more, FS2 will (most likely) crash.

I've put together a demo. Just extract that archive in your FS2 folder, select the test directory as your mod and start the patched build (which you have to compile yourself, sorry).
Here is the patch.

What do you think?
« Last Edit: March 10, 2014, 02:48:20 pm by ngld »

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
Wow, I can't believe I missed this post. Give me a few days to look into it and test it.

Also, can Multiplayer and F3 Lab be allowed options?

EDIT: First thoughts. I understand the menu.tbl route completely and it makes sense. But requiring menu.tbl recreates a mainhall limitation that we recently removed, that being modularness. Menu.tbl is not modular and so any mainhall that needs it for these functions loses that ability. Would it be possible to either make menu.tbl modular (I'm not hopeful, it's syntax is weird and unlike any other table), or incorporate these necessary table lines in a "header" of the mainhall.tbl? I dunno, just ideas off the top.

For the number to hex thing. Any chance we can make that easier on the modder like allowing the specification of the color code or something?
« Last Edit: March 16, 2014, 09:28:24 pm by mjn.mixael »
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Axem

  • 211
Re: [Request] New Mainhall Capabilities
So I was talking to mjn with this, playing with it also and I have a suggestion.

It seems to me that your planned way of doing things is when we hit a "script" button, we leap into the scripting state and then we route to other screens depending on what hv.MenuButton is. It makes sense anyway. But there's a problem with that, there's quite a few uses of GS_EVENT_PREVIOUS_STATE that the Exit button of those screens use. Eg: the F3 lab. When we go to the previous state, we go back to the scripting state which says... go to F3 lab.

So maybe instead could you have it so $On State End (or something else that makes sense) will have available the MenuButton variable? So then you could so something like this...

Code: [Select]
$State: GS_STATE_MAIN_MENU
$On State End: [

if hv.MenuButton == '6' then
ba.postGameEvent(ba.GameEvents["GS_EVENT_OPTIONS_MENU"])
end

if hv.MenuButton == '7' then
ba.postGameEvent(ba.GameEvents["GS_EVENT_LAB"])
end

]

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
Yup, 7 clickable & animated areas. Win.

To recap. This. Is. Awesome. Here are a few final notes from my testing.

  • The scripting should do more what Axem requested to avoid endless state-loops.
  • None of the Multiplayer states really work. They would load the interface and then promptly return to the mainhall. It'd be handy if that was a built-in option though, because the option already exists in the code somewhere thanks to the old Multiplayer players. (Readyroom was replaced with Multiplayer). Perhaps any other generic-use states?
  • +Door Description should probably link into the XSTR stuff for translations? Yes? No? Maybe? Does it already?
  • Menu.tbl needs to be modular or some way included so as to not suddenly bring that limitation back to mainhalls.
  • **** yeah

EDIT: I thought about the menu.tbl thing a bit... so each door index in the mainhall.tbl has a menu.tbl line that corresponds to it, right? And all that does is match the door index to a hex value that leads to a color for the mask file, right? Could we just include this line or some variation of it in the mainhall.tbl and then not require menu.tbl at all for that? Perhaps we'd have +Door Value added as well simple include the info that is currently found in menu.tbl. I dunno, just another idea I had.
« Last Edit: March 17, 2014, 12:48:13 am by mjn.mixael »
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
End-of-the-month BUMP!

Original coder of this neat patch is not responding to my PMs. Halp. I refuse to let this die. :)
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Black Wolf

  • Twisted Infinities
  • 212
  • Hey! You! Get off-a my cloud!
    • Visit the TI homepage!
Re: [Request] New Mainhall Capabilities
I didn't see that video before - it's brilliant! Does this mean Axem's new fiction viewer thing wont have to bump the barracks any more?
TWISTED INFINITIES · SECTORGAME· FRONTLINES
Rarely Updated P3D.
Burn the heretic who killed F2S! Burn him, burn him!!- GalEmp

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
I didn't see that video before - it's brilliant! Does this mean Axem's new fiction viewer thing wont have to bump the barracks any more?

Yup!
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
So.. guess ngld isn't coming back to this. Who do I bribe now?
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Goober5000

  • HLP Loremaster
  • Moderator
  • 214
    • Goober5000 Productions
Re: [Request] New Mainhall Capabilities
Me!  But then you have to put up with my characteristic tardiness.

(And I'm not claiming exclusive implementation rights either.  Other coders, feel free to volunteer yourselves!)

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
(Bi)Monthly Bump!
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline ngld

  • Administrator
  • 29
  • Knossos dev
Re: [Request] New Mainhall Capabilities
Um... sorry for my long absence.  :nervous:

So the remaining changes are:
  • Make hv.MenuButton available to "$On State End".
  • Fix Multiplayer.
  • Make sure translations work for "+Door description". (They should be handled by parselo already but I'm not sure.)
  • Add "+Door Mask" (any better ideas for the the option name?) to avoid depending on menu.tbl.
    I've avoided this because I'll probably have to make some changes to SnazzyUI to make this work.
  • Anything I forgot?

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
That looks about right.

Could be +Door Mask Value: or +Door Mask Hex.

That one's pretty important because without it we lose one of the biggest upgrades to mainhalls (modularability) we've gotten so far.
« Last Edit: June 25, 2014, 03:16:39 pm by mjn.mixael »
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: [Request] New Mainhall Capabilities
thought this was what that webkit stuff was for.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
Nope. This is not a thread about WebKit... That is a separate issue, and separate thread.

This is about extended features that don't require new library integration into FSO, thank you.
« Last Edit: June 25, 2014, 08:48:36 pm by mjn.mixael »
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
Re: [Request] New Mainhall Capabilities
ok, I had gotten the impression that was the way forward, nevermind then.
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline ngld

  • Administrator
  • 29
  • Knossos dev
Re: [Request] New Mainhall Capabilities
I've updated the patch and the example.

The new patch ignores the menu.tbl completely (which means that keyboard shortcuts won't work anymore).
The "+Door mask value" tells FSO which color the masked area has. You can put a decimal or hexadecimal number here. (i.e. 255 means (255, 255, 255) aka #FFFFFF, 0x01 means (1, 1, 1) aka #010101)
The "+Door action" can be one of Exit, Barracks, Readyroom, Techroom, Options, Campaigns, Load Mission, Quickstart, Skilllevel or "Script <LUA code>".
If "+Door description" is "default" it will use the hardcoded default description.

Code: [Select]
+Door mask value:      0xf9
+Door mask value:      254
+Door mask value:      253
+Door mask value:      252
+Door mask value:      251
+Door mask value:      250
+Door mask value:      255
+Door action:          Exit
+Door action:          Barracks
+Door action:          Readyroom
+Door action:          Techroom
+Door action:          Script ba.postGameEvent(ba.GameEvents["GS_EVENT_LAB"])
+Door action:          Script testMessage()
+Door action:          Script ba.postGameEvent(ba.GameEvents["GS_EVENT_SCRIPTING"])
+Door description:     Exits are to the rear, left and right
+Door description:     To the barracks
+Door description:     Launch the mission...
+Door description:     View the tech
+Door description:     Script 4
+Door description:     Script 5
+Door description:     Script 6

I've fixed the multiplayer, however for it to work the third door has to be the Readyroom door. To get the default multiplayer description you have to set the description to "default".

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
I'll test this when I get home. Can you explain the multiplayer bit more? It seems to mean that you can't have ReadyRoom and Multiplayer coexist.

Did you fix the script issue where we had loops. (I think related to $On State End)?
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.

 

Offline ngld

  • Administrator
  • 29
  • Knossos dev
Re: [Request] New Mainhall Capabilities
Multiplayer and Readyroom can't coexist because you need a single player pilot for the Readyroom and a multiplayer pilot for Multiplayer.
If the player is using a multiplayer pilot and the third door has the action Readyroom, then FSO will automatically change it to Multiplayer.

A better way to do this might be to add a Start action which uses the Readyroom action when in single player mode and Multiplayer when in multi mode.
The script issue should be solved since I'm not switching to scripting state anymore. I'm simply running the LUA code in the mainhall.
You can still change the game's state using LUA (using ba.postGameEvent) but you can also do LUA scripting on the mainhall.

In my example you can click on the campaign screen to toggle a short text in the upper left corner.

 

Offline mjn.mixael

  • Cutscene Master
  • 212
  • Chopped liver
    • Steam
    • Twitter
Re: [Request] New Mainhall Capabilities
The Multiplayer may be worth a deeper look (which may go beyond this patch) because I'm under the impression that player files are no longer distinguished between single and multi. I suspect the difference now is only interface-deep, but I could be wrong.
Cutscene Upgrade Project - Mainhall Remakes - Between the Ashes
Youtube Channel - P3D Model Box
Between the Ashes is looking for committed testers, PM me for details.
Freespace Upgrade Project See what's happening.