Author Topic: Submenu Resize: Request (Solved)  (Read 736 times)

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Submenu Resize: Request (Solved)
« on: December 17, 2019, 06:52:13 PM »
More or less I need to establish what string of text I would need to input in a script to refresh a submenu. I will try to explain; you click on a submenu and it populates with buttons. What if I want to simulate that mouse click with button interaction, so that when I click a specific button it re-opens that submenu? I am not very well versed on the python lingo that BC uses, so I doubt it would be so easy, but I am looking for something along the lines of
Code: [Select]
pSpecial.SetOpen() or pSpecial.SetActive() or something simple and not too in depth. If it helps, we deal with TGString menus here...
Code: [Select]
pSpecial = App.STMenu_CreateW(App.TGString("Special Options")) #Unfinished
pScienceMenu.PrependChild(pSpecial)

Or am I looking to delete and re-add the whole menu ?
Code: [Select]
pScienceMenu.DeleteChild(pSpecial)
pScienceMenu.PrependChild(pSpecial)

Help

???

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Submenu Refresh: Request for assistance
« Reply #1 on: December 18, 2019, 04:15:29 PM »
I'm not sure if i really understand what you want to do,
but I *think* some of the BCS mods did something similar.
Probably Emergency Repair or the Silent Running one.

You could also look into the advanced scanning mod. I just cannot remember if that was part or feature of KM, or an entirely different mod that added that feature...

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Refresh: Request for assistance
« Reply #2 on: December 18, 2019, 07:52:28 PM »
I have some buttons that are ship script/race specific, and changing ships makes the buttons appear and disappear... well when the new ones appear, you have to close the parent menu and reopen it to see the new button(s). I need to do that automatically, perhaps via timer. It's just I don't know what set of commands I would need to type up to get the desired result, even though I know what need to be done, I don't know how... but I know there should be a way to do it, or at the very least some workaround...

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Submenu Refresh: Request for assistance
« Reply #3 on: December 19, 2019, 12:15:57 PM »
There are a few functions in the APP.py that you could try.

For STMenu there are:
Code: [Select]
STMenu.SetOpened = new.instancemethod(Appc.STMenu_SetOpened, None, STMenu)
STMenu.ClearOpened = new.instancemethod(Appc.STMenu_ClearOpened, None, STMenu)
STMenu.IsOpened = new.instancemethod(Appc.STMenu_IsOpened, None, STMenu)
[...]
STMenu.ForceUpdate = new.instancemethod(Appc.STMenu_ForceUpdate, None, STMenu)
STMenu.Open = new.instancemethod(Appc.STMenu_Open, None, STMenu)
STMenu.Close = new.instancemethod(Appc.STMenu_Close, None, STMenu)
STMenu.ResizeToContents = new.instancemethod(Appc.STMenu_ResizeToContents, None, STMenu)

The forceUpdate function may be something to look into.

Another other method you could try is:
Code: [Select]
TGUIObject.Layout = new.instancemethod(Appc.TGUIObject_Layout, None, TGUIObject)
That should work on the menu as well.
If none of those work, calling remove and prepend like you suggested should also work.

If that is only to be done when the player changes the ship, you should use an event-listener (BroadcastPythonFuncHandler) instead of a timer.
Look e.g., at the Emergency Repair (ESR.py) for that.

Err, looking at that right now, It seems that what happens in "def GameRestart()" is actually removing and rebuilding the entire menu, like you suggested earlier.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Refresh: Request for assistance
« Reply #4 on: December 19, 2019, 12:26:12 PM »
Resize to contents sounds more like what I'm looking for, it is my belief that the new button populates when the trigger button is pressed, that the menu never resizes to accommodate the new button. You have been most helpful, thank you again :)

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Resize: Request (Solved)
« Reply #5 on: December 19, 2019, 01:34:42 PM »
This seems to do the trick, there is a small bug that I might fix (when the button disappears it leaves a blank space, when before it did not)

Quote
pSpecial.ResizeToContents()

where pSpecial is the parent menu button which needs resizing to accommodate the new child(ren).

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Submenu Resize: Request (Solved)
« Reply #6 on: December 19, 2019, 05:02:44 PM »
Great that you got it to work!
The layout function may remove that blank space. But I'm unsure whether you'd need to call that before or after the resize one.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Resize: Request (Solved)
« Reply #7 on: December 19, 2019, 05:10:23 PM »
It goes away by adding another instance of ResizeToContents within the else: clause (which sets the button notvisible)

Also had to add those pesky PythonFuncHandlers that reset the subroutine after death/respawn. I just took some video, uploading to youtube as I type this.. link coming soon
Spoiler: show

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Submenu Resize: Request (Solved)
« Reply #8 on: December 20, 2019, 06:43:59 AM »
Ah, the good old shield inversion. I wanted to add something like this once, but never got the beam part to work as i wanted...

You know that Chain Reaction Pulsar, Point Defence, and Gemini Effect (called SelfManheim) mods were made by USS Frontier, Defiant, and Sovereing/Mario respectively?

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Resize: Request (Solved)
« Reply #9 on: December 20, 2019, 08:52:54 AM »
I believe the simplest solution for the SI beam would be to add some kind of "stick" model to the pSet, attach it to the warbird (to the shield bubble maybe?) and somehow otherwise get it to move with the warbird. At this point, I do not plan to add the visual effects because of the level of difficulty doing so, but rather use sound effects to show the mod is active and working.

I am aware of the chain reaction pulse mod but could not locate a download, self manheim I now have the files for and I do plan to use (but I will change from self to target with friendly group check), but I had no idea there was a point defense mod. I was planning on constructing the code for CRP and PDP, however not sure how I would be incorporating the PDP, perhaps a small inaccuracy so it's not overpowered. I had not planned to add models to pSet yet but I do know that it is possible to do so, and I may be experimenting with the event handlers for shield hits.. I think the issue would arise where you try to set a path for the new model to get it to track toward the target as the target moves randomly. But I won't be touching anything like that fora long while, I tend not to work on things that are out of my scope of ability until my ability is stronger

Offline KrrKs

  • Posts: 461
  • Cookies: 25
Re: Submenu Resize: Request (Solved)
« Reply #10 on: December 20, 2019, 10:17:14 AM »
IIRC the point defence mod is part of KM, and used for the Sovereign class. I vaguely remember there being a button in the tactical menu that activated it, but cannot recall much more than that.
Look for a PointDefence.py in the QBAutostart directory.

The Chain Reaction Pulsar mod can be found on filefront again:
https://www.gamefront.com/games/bridge-commander/file/chain-reaction-pulsar

Edit:
I'm also pretty sure that the 'Corbomite Reflector' or whatever that was called in Armada is available as a DTech or FTech, albeit working 'only' against torpedoes.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Submenu Resize: Request (Solved)
« Reply #11 on: December 20, 2019, 11:27:55 AM »
I think I elected not to use the Corbomite Reflector simply because that would make the Sovereign overpowered and imbalanced at that point. Though I could use a timer and a massive cooldown like I would be doing with the Gemini Effect.. I think I have planned about 15 special weapons for certain ships. Thanks for the link for the CRP I will go ahead and add that to my repository. And now that you mentioned it, yes I do remember there being a point defense button in KM, I believe it was under the Technologies menu but cant recall at this point