Author Topic: Modifying the shield display window  (Read 1569 times)

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Modifying the shield display window
« on: July 18, 2012, 10:34:34 PM »
The ShieldPercentages script draws on and periodically refreshes the shield display window.

I want to do the same thing, more or less, in my script. It'd be awesome if when the player is targeting a ship that has primary/secondary shield generators the shield display window would tell you what generator is active on the target ship. Although with the simple logic behind how the AI chooses what their active generator it somehow seems natural that there be an indicator of this on the GUI somewhere. There would be the text "Primary active" or "Secondary active" depending on circumstances.

It would be good if the displayed text were only updated when something changed with the generators or the players targeted ship but it could just as well be checked every X seconds like ShieldPercentages does it.

Just one tiny problem about me getting this functionality off the ground. I have little to no idea as to how ShieldPercentages works and thus how I could fit an adaption of it to my needs  :idk:

 :help:
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: Modifying the shield display window
« Reply #1 on: July 19, 2012, 02:27:49 AM »
Why don't you just copy from the shield percentages?

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: Modifying the shield display window
« Reply #2 on: July 19, 2012, 10:35:30 AM »
Why don't you just copy from the shield percentages?
I'm trying but i've never messed about with the GUI before. Plus what i'm doing is slightly different from what you're doing in ShieldPercentages.

You know your display is going to exist permanately forever as long as the player is playing. My display element is supposed only exist as long as the targeted ship is one with primary and secondary shield generators.
You update your display with a timer that goes off every X seconds whilst I only want to update the element of my display when you switch targets to another ship or a generator goes online/offline.

I've made some progress and am reading over ShieldPercentages but it's all new stuff to me. On the plus I have found an event handler for when the player changes targets.

Code: [Select]
# updates display when player targets a different ship configured with primary/secondary shields
def TargetChange(pObject, pEvent):
print "TargetChange() -----------------------------"
global prevPlyrTargID
pPlyrShip = App.ShipClass_Cast(MissionLib.GetPlayer())
pPlyrTarg = App.ShipClass_Cast(pPlyrShip.GetTarget())
if pPlyrTarg:
print "Players targeted ship type =", GetShipType(pPlyrTarg)
pPlyrTargID = pPlyrTarg.GetObjID()
if pPlyrTargID in shipShieldVals.keys():
if prevPlyrTargID != 0:
if prevPlyrTargID != pPlyrTargID:
# player has switched ship targets
print "Switched ship targets to ship with primary/secondary generators, text would have been written"
else:
# first target, create/draw text
prevPlyrTargID = pPlyrTargID
print "First target, text would have been written"
else:
# not a primary/secondary generator ship, clear text from shield display
print "Not a primary/secondary shield generators ship, text would have been cleared"
prevPlyrTargID = 0
else:
# no target, clear text from shield display
print "No target, text would have been cleared"
prevPlyrTargID = 0
print '\n\n'
pObject.CallNextHandler(pEvent)
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: Modifying the shield display window
« Reply #3 on: July 19, 2012, 11:02:33 AM »
You know your display is going to exist permanately forever as long as the player is playing. My display element is supposed only exist as long as the targeted ship is one with primary and secondary shield generators.
You update your display with a timer that goes off every X seconds whilst I only want to update the element of my display when you switch targets to another ship or a generator goes online/offline.
Not totally correct.
I update two displays. the Player and the Target. The target is only visible when
1. Player has a target
2. Targets has shields active
3. Player has working sensors
4. Target is in sensor range.
5. Target is identified.

If one of the five fails the target shield information is not visible.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: Modifying the shield display window
« Reply #4 on: July 19, 2012, 02:07:31 PM »
What is this for?

Code: [Select]
NonSerializedObjects = (
"g_pShieldPercentageTimer"
)

I can't find NonSerializedObjects used anywhere in the script.
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: Modifying the shield display window
« Reply #5 on: July 19, 2012, 02:13:42 PM »
You can safely ignore that for now. It allows Single Player Save/Load to work.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: Modifying the shield display window
« Reply #6 on: July 19, 2012, 11:28:40 PM »
YES! Success  :thumbsup: yet gain Defiant  :angel

Although, now i've succeeded in doing exactly what I wanted to do with the Shield display i'm not sure if I want the text there. Maybe it's because the display window is so small or the text is so big in comparison to the numerical shield percentage values but, somehow, my addition to the window makes it look cluttered  :(

Maybe it's just that i'm so used to that window not having the text. What do ya think?
http://imageshack.us/f/40/screenshot000c.png/
Great men are not peacemakers! Great men are conquerors!

Offline Defiant

  • Posts: 398
  • Cookies: 1105
    • BC: Kobayashi Maru
Re: Modifying the shield display window
« Reply #7 on: July 20, 2012, 03:06:31 AM »
looks fine for me.

Offline Bat66wat6

  • Posts: 144
  • Cookies: 34
  • Running custom BC 1.1
Re: Modifying the shield display window
« Reply #8 on: July 20, 2012, 10:56:15 PM »
looks fine for me.
Yeah, I guess it's just because that part of the interface has never changed and so any difference stands out.

I put the text as far up in the corner as I could and the only thing that's slightly off-putting really I guess is that when it says "Secondary" the word almost overlaps the ship model. Still... the feature gives more positive than negative as there's no room for confusion as to what generator on your target is active.

Again, thanks for the input Defiant  :)
Great men are not peacemakers! Great men are conquerors!