Author Topic: Idea: Bridge Preview (concept)  (Read 1348 times)

Offline yochenhsieh

  • Posts: 46
  • Cookies: 2
    • SFC3: Rebalance Expansion
Idea: Bridge Preview (concept)
« on: August 10, 2018, 09:53:36 PM »
Hello,
I'm not sure if this kind of feature has been made before. Now we have lots of bridges and some of them bearing similar names, I wonder if it's possible to make a bridge preview in quick battle setup? Concept pic below (not real thing, just an idea):


Offline Morgan

  • Moderator
  • Posts: 1340
  • Cookies: 65535
Re: Idea: Bridge Preview (concept)
« Reply #1 on: August 10, 2018, 11:04:46 PM »
I imagine it's possible.  The Interstellar Library from KM has icons for each race, so I image doing something like this would be similar.  I don't know enough to do it, and our remaining scripters might have things going on of their own.  Still a cool concept.

Offline Lurok91

  • Posts: 1309
  • Cookies: 2062
  • SPMod Developer (Retired)
    • Lurok91 Mods
Re: Idea: Bridge Preview (concept)
« Reply #2 on: August 11, 2018, 11:14:01 AM »
Excellent concept  :thumbsup:

I imagine it would involve creating 'small' icons/tga files for each bridge, probably in a separate folder.  And script direct to that folder.

But a great idea.

Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Idea: Bridge Preview (concept)
« Reply #3 on: August 11, 2018, 11:54:11 AM »
A great idea indeed. Never thought about that. :)
TaH pagh, Tah be.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Idea: Bridge Preview (concept)
« Reply #4 on: August 31, 2018, 09:33:33 PM »
I think this can be done. I have messed with Interstellar Library, so I know a little about how that file goes. The clue on getting it implemented would come from the ship icon right above "Ship Description", as this will need to be copied, and a def created for the widget (blank space which holds our bridge preview icons).

Definitely sounds doable, and fairly simple. Fairly. I shall give this an attempt this weekend. Can you provide some images perhaps? I simply have no time to do it as I will be focused on scripting. If anyone could create some.. Galaxy and Sovereign bridge images for now should work. I have looked over the Quick Battle script. Very long, drawn out file. A few more lines shouldnt hurt yeah?

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Idea: Bridge Preview (concept)
« Reply #5 on: September 01, 2018, 12:38:59 PM »
Looking deeper, there are actually 2 quick battle types, at least in my install. One is under a Custom submenu in the Mission selection menu called QuickBattleGame, the other one is Quick Battle. The one you have pictured is of Quick Battle, which is indeed the longer file. I'll give it a go and see what I come up with.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Idea: Bridge Preview (concept)
« Reply #6 on: September 01, 2018, 08:58:36 PM »
I believe I have most of the necessary code in place in the QuickBattle.py. I successfully moved the Ship Icon to the test location. After changing some names around we are now ready to create a subfolder in the Icons folder and fill it up with icons, then figure out how to grab the strings by name (which is what I am now working on). For now, a blank space lies in our test location. Folder has been cloned from the Races icons, with the icons within being renamed to Sovereign.tga, Galaxy.tga, etc just to get the naming system implemented and coded. I am not sure whether or not a Bridges.TGL will be required at this time, but possibly.

Offline Tethys

  • -=USF=- Co-Leader
  • Posts: 256
  • Cookies: 89
Re: Idea: Bridge Preview (concept)
« Reply #7 on: September 02, 2018, 04:43:41 PM »
Update: It seems I will have to add some code to the Foundation.py (have done some, but incomplete/untested at this time), and I am still having trouble linking the iconName with the new folder containing the new icons. I cannot seem to find the code responsible for grabbing the location of the ships icons, therefore I cannot complete the project at this time. I did successfully clear out some space for the icon, and created a glass pane with a blank space in the QB Setup XO menu, next to the bridge list, underneath the systems/regions selection pane. If anyone wants to have a look, I can upload the modified files for download. I do think this is still very possible; a majority of the work has been done to implement the bridge preview, however it now needs the touch of a seasoned scripter to complete.

Edit: My thought is that perhaps some code needs to be added to the bridges in the scripts\Custom\Autoload folder and/or elsewhere

Update 9/3/18: I believe I have located the scripts that control where the icons are to be located. When I get some time, I will see if I can add a script for locating the bridge preview icons. If all goes well, you should be hearing from me again soon.

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.
Re: Idea: Bridge Preview (concept)
« Reply #8 on: September 28, 2020, 01:36:50 PM »
 :hi:

I'll revive this thread  :vb_how:

I've had the same idea for a long time  :wink:

My current menu:




Offline FekLeyr Targ

  • DS9FX Team
  • Posts: 490
  • Cookies: 537
Re: Idea: Bridge Preview (concept)
« Reply #9 on: September 28, 2020, 03:19:36 PM »
And the bridge preview will be placed on the empty spot beside the bridge menu?

By the way: Is this original quickbattle or quickbattle replacement (QBR)?
TaH pagh, Tah be.

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.
Re: Idea: Bridge Preview (concept)
« Reply #10 on: September 28, 2020, 03:49:01 PM »
And the bridge preview will be placed on the empty spot beside the bridge menu?
Yes!  :)

Quote
By the way: Is this original quickbattle or quickbattle replacement (QBR)?
BCDir/scripts/QuickBattle/QuickBattle.py

QBR = BCDir/scripts/Custom/QuickBattleGame ?

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.
Re: Idea: Bridge Preview (concept)
« Reply #11 on: September 28, 2020, 04:43:11 PM »
 :hi:

example:


Ambassador:


Voyager:


Sovereign:

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Idea: Bridge Preview (concept)
« Reply #12 on: September 28, 2020, 09:20:07 PM »
So this is a concept or?
Acta, non verba.
aka USS Sovereign

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Idea: Bridge Preview (concept)
« Reply #13 on: September 29, 2020, 01:34:23 AM »
Anything else other than 128x128, 256x256... is useless as an icon for BC. The initial suggestion is not that difficult to do as well. Though I don't understand why Foundation at all needed to be changed?

Use this patch to adjust to your linking. Enjoy.

Spoiler: show
Code: [Select]
"""Add bridge preview to QB Pane as suggested on the forums"""

import App
import Foundation
import QuickBattle.QuickBattle

menuScrollers = None
try:
    import Custom.Sneaker.MenuScrollers

    menuScrollers = Custom.Sneaker.MenuScrollers
except:
    pass

QB = QuickBattle.QuickBattle
originalBuildDialog = QB.BuildDialog

REGION_MENU_HEIGHT = 0.5275
BRIDGE_MENU_WIDTH = 0.5275
BRIDGE_MENU_ICON_X_POS = 0.33
iconRegistry = {}
qbIcons = "QBIcons"
iconPath = "data/Icons/Bridges/%s.tga"
icons = None
iconsPane = None

if int(Foundation.version[0:8]) >= 20030222:
    print("Adding bridge preview pane...")


    def RegisterQBIcons(group=None):
        global iconRegistry
        if not group:
            group = App.g_kIconManager.CreateIconGroup(qbIcons)
            App.g_kIconManager.AddIconGroup(group)

        if len(iconRegistry) == 0:
            position = 1
            for bridge in Foundation.bridgeList:
                path = iconPath % bridge.name
                try:
                    textureHandle = group.LoadIconTexture(path)
                    if textureHandle > -1:
                        group.SetIconLocation(position, textureHandle, 0, 0, 128, 128)
                        iconRegistry[bridge.name] = {'path': path, 'exists': 1, 'position': position}
                        position = position + 1
                    else:
                        iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                except:
                    iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                    pass
        else:
            for k, v in iconRegistry:
                textureHandle = group.LoadIconTexture(v['path'])
                group.SetIconLocation(v['position'], textureHandle, 0, 0, 128, 128)


    def GetQBIcon(bridgeName):
        global iconRegistry

        if not bridgeName:
            return None

        if iconRegistry[bridgeName]['exists']:
            return iconRegistry[bridgeName]['position']
        return None


    def GeneratePlayerBridgeMenu(iShipsUnlocked1):
        global icons, iconsPane
        # Create menus for the player's ship
        # making the bridge menu the slightest bit longer
        pShipMenu = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        iconsPane = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        icons = App.TGIcon_Create(qbIcons, App.SPECIES_UNKNOWN)
        icons.Resize(QB.BRIDGE_MENU_WIDTH, QB.BRIDGE_MENU_HEIGHT)
        RegisterQBIcons()
        App.g_kIconManager.RegisterIconGroup(qbIcons, __name__, "RegisterQBIcons")
        LoadIcon()
        iconsPane.AddChild(icons)

        pStylizedWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize",
                                                       QB.g_pMissionDatabase.GetString("Select Player Bridge"))
        pStylizedWindow.SetUseScrolling(1)

        # making the bridge menu the slightest bit longer
        pStylizedWindow.SetFixedSize(BRIDGE_MENU_WIDTH,
                                     QB.BRIDGE_MENU_HEIGHT)
        pStylizedWindow.SetTitleBarThickness(QB.BAR_HEIGHT)
        pStylizedWindow.AddChild(iconsPane, BRIDGE_MENU_ICON_X_POS, 0.01)
        pStylizedWindow.AddChild(pShipMenu)
        QB.g_pPlayerPane.AddChild(pStylizedWindow, QB.BRIDGE_MENU_X_POS, QB.BRIDGE_MENU_Y_POS)

        ###############################################################################
        # Dasher42's additions

        QB.bridgeMenuBuilder(QB.qbGameMode.bridgeList, pShipMenu, QB.ET_SELECT_BRIDGE_TYPE, QB.g_pXO)
        pShipMenu.Resize(pShipMenu.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         pShipMenu.GetTotalHeightOfChildren())
        iconsPane.Resize(iconsPane.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         iconsPane.GetTotalHeightOfChildren())
        pStylizedWindow.Layout()
        pStylizedWindow.InteriorChangedSize()

        return pStylizedWindow


    def BuildDialog(bPreservePane=0):
        addHandler = QB.g_bAddedUIHandlers
        originalBuildDialog(bPreservePane)
        if not addHandler:
            QB.g_pXO.AddPythonFuncHandlerForInstance(QB.ET_SELECT_BRIDGE_TYPE, __name__ + ".HandleBridgeIcon")


    def HandleBridgeIcon(pObject, pEvent):
        LoadIcon(Foundation.bridgeList[pEvent.GetInt()].name)
        pObject.CallNextHandler(pEvent)


    def LoadIcon(bridgeName=None):
        global iconRegistry
        if not bridgeName:
            for bridge in Foundation.bridgeList:
                if bridge.bridgeString == QB.g_sBridgeType:
                    bridgeName = bridge.name
                    break
        icon = GetQBIcon(bridgeName)
        if icon:
            icons.SetVisible()
            icons.SetIconNum(icon)
            icons.SizeToArtwork()
        else:
            icons.SetNotVisible()


    class FoundationPreviewPane:
        def __init__(self):
            self.__funcoverride__()

        def __funcoverride__(self):
            QB.REGION_MENU_HEIGHT = REGION_MENU_HEIGHT
            QB.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu
            QB.BuildDialog = BuildDialog
            if menuScrollers:
                menuScrollers.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu


    Foundation.FoundationPreviewPane = FoundationPreviewPane()

Acta, non verba.
aka USS Sovereign

Offline JimmyB76

  • Posts: 6423
  • Cookies: 421
Re: Idea: Bridge Preview (concept)
« Reply #14 on: September 29, 2020, 11:13:51 AM »
this is a neat idea!

and i really like Haxxor's QB Menu setup!  that looks so much better!

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.
Re: Idea: Bridge Preview (concept)
« Reply #15 on: September 29, 2020, 05:24:01 PM »
Quote
this is a neat idea!

and i really like Haxxor's QB Menu setup!  that looks so much better!

Thx Jimmy :thumbsup:

Anything else other than 128x128, 256x256... is useless as an icon for BC. The initial suggestion is not that difficult to do as well. Though I don't understand why Foundation at all needed to be changed?

Use this patch to adjust to your linking. Enjoy.

Spoiler: show
Code: [Select]
"""Add bridge preview to QB Pane as suggested on the forums"""

import App
import Foundation
import QuickBattle.QuickBattle

menuScrollers = None
try:
    import Custom.Sneaker.MenuScrollers

    menuScrollers = Custom.Sneaker.MenuScrollers
except:
    pass

QB = QuickBattle.QuickBattle
originalBuildDialog = QB.BuildDialog

REGION_MENU_HEIGHT = 0.5275
BRIDGE_MENU_WIDTH = 0.5275
BRIDGE_MENU_ICON_X_POS = 0.33
iconRegistry = {}
qbIcons = "QBIcons"
iconPath = "data/Icons/Bridges/%s.tga"
icons = None
iconsPane = None

if int(Foundation.version[0:8]) >= 20030222:
    print("Adding bridge preview pane...")


    def RegisterQBIcons(group=None):
        global iconRegistry
        if not group:
            group = App.g_kIconManager.CreateIconGroup(qbIcons)
            App.g_kIconManager.AddIconGroup(group)

        if len(iconRegistry) == 0:
            position = 1
            for bridge in Foundation.bridgeList:
                path = iconPath % bridge.name
                try:
                    textureHandle = group.LoadIconTexture(path)
                    if textureHandle > -1:
                        group.SetIconLocation(position, textureHandle, 0, 0, 128, 128)
                        iconRegistry[bridge.name] = {'path': path, 'exists': 1, 'position': position}
                        position = position + 1
                    else:
                        iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                except:
                    iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                    pass
        else:
            for k, v in iconRegistry:
                textureHandle = group.LoadIconTexture(v['path'])
                group.SetIconLocation(v['position'], textureHandle, 0, 0, 128, 128)


    def GetQBIcon(bridgeName):
        global iconRegistry

        if not bridgeName:
            return None

        if iconRegistry[bridgeName]['exists']:
            return iconRegistry[bridgeName]['position']
        return None


    def GeneratePlayerBridgeMenu(iShipsUnlocked1):
        global icons, iconsPane
        # Create menus for the player's ship
        # making the bridge menu the slightest bit longer
        pShipMenu = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        iconsPane = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        icons = App.TGIcon_Create(qbIcons, App.SPECIES_UNKNOWN)
        icons.Resize(QB.BRIDGE_MENU_WIDTH, QB.BRIDGE_MENU_HEIGHT)
        RegisterQBIcons()
        App.g_kIconManager.RegisterIconGroup(qbIcons, __name__, "RegisterQBIcons")
        LoadIcon()
        iconsPane.AddChild(icons)

        pStylizedWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize",
                                                       QB.g_pMissionDatabase.GetString("Select Player Bridge"))
        pStylizedWindow.SetUseScrolling(1)

        # making the bridge menu the slightest bit longer
        pStylizedWindow.SetFixedSize(BRIDGE_MENU_WIDTH,
                                     QB.BRIDGE_MENU_HEIGHT)
        pStylizedWindow.SetTitleBarThickness(QB.BAR_HEIGHT)
        pStylizedWindow.AddChild(iconsPane, BRIDGE_MENU_ICON_X_POS, 0.01)
        pStylizedWindow.AddChild(pShipMenu)
        QB.g_pPlayerPane.AddChild(pStylizedWindow, QB.BRIDGE_MENU_X_POS, QB.BRIDGE_MENU_Y_POS)

        ###############################################################################
        # Dasher42's additions

        QB.bridgeMenuBuilder(QB.qbGameMode.bridgeList, pShipMenu, QB.ET_SELECT_BRIDGE_TYPE, QB.g_pXO)
        pShipMenu.Resize(pShipMenu.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         pShipMenu.GetTotalHeightOfChildren())
        iconsPane.Resize(iconsPane.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         iconsPane.GetTotalHeightOfChildren())
        pStylizedWindow.Layout()
        pStylizedWindow.InteriorChangedSize()

        return pStylizedWindow


    def BuildDialog(bPreservePane=0):
        addHandler = QB.g_bAddedUIHandlers
        originalBuildDialog(bPreservePane)
        if not addHandler:
            QB.g_pXO.AddPythonFuncHandlerForInstance(QB.ET_SELECT_BRIDGE_TYPE, __name__ + ".HandleBridgeIcon")


    def HandleBridgeIcon(pObject, pEvent):
        LoadIcon(Foundation.bridgeList[pEvent.GetInt()].name)
        pObject.CallNextHandler(pEvent)


    def LoadIcon(bridgeName=None):
        global iconRegistry
        if not bridgeName:
            for bridge in Foundation.bridgeList:
                if bridge.bridgeString == QB.g_sBridgeType:
                    bridgeName = bridge.name
                    break
        icon = GetQBIcon(bridgeName)
        if icon:
            icons.SetVisible()
            icons.SetIconNum(icon)
            icons.SizeToArtwork()
        else:
            icons.SetNotVisible()


    class FoundationPreviewPane:
        def __init__(self):
            self.__funcoverride__()

        def __funcoverride__(self):
            QB.REGION_MENU_HEIGHT = REGION_MENU_HEIGHT
            QB.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu
            QB.BuildDialog = BuildDialog
            if menuScrollers:
                menuScrollers.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu


    Foundation.FoundationPreviewPane = FoundationPreviewPane()



 :bow: :bow: :bow:
Thank you for time and code !!!!

I modified your code a little bit. I create 128 Icons for low resolution and 256 Icons for higher then 1024*768

Spoiler: show

Code: [Select]
#"""Add bridge preview to QB Pane as suggested on the forums"""
###############################################################################
# Filename: 000-Foundation-Bridge-Preview-2020929.py
#
# by Mario, aka USS Sovereign
#
# A quick battle bridge preview
#
# Created:  2020/09/29 - USS Sovereign, modified by HaxxOR1337
###############################################################################
import App
import Foundation
import QuickBattle.QuickBattle

menuScrollers = None
try:
    import Custom.Sneaker.MenuScrollers

    menuScrollers = Custom.Sneaker.MenuScrollers
except:
    pass

QB = QuickBattle.QuickBattle
originalBuildDialog = QB.BuildDialog
#####################################
# edit for precise position
#####################################
REGION_MENU_HEIGHT          = 0.5
BRIDGE_MENU_X_POS = 0.508
BRIDGE_MENU_Y_POS = 0.518
BRIDGE_MENU_WIDTH = 0.464
BRIDGE_MENU_ICON_X_POS      = 0.23

iconRegistry = {}
qbIcons = "QBIcons"
#####################################
# for low resolution /128/
#   800x600, 1024x1024, 1280x1024
# for higher resolution /256/
#####################################
iconPath = "data/Icons/Bridge/256/%s.tga"
icons = None
iconsPane = None

if int(Foundation.version[0:8]) >= 20030222:
    print("Adding bridge preview pane...")


    def RegisterQBIcons(group=None):
        global iconRegistry
        if not group:
            group = App.g_kIconManager.CreateIconGroup(qbIcons)
            App.g_kIconManager.AddIconGroup(group)

        if len(iconRegistry) == 0:
            position = 1
            for bridge in Foundation.bridgeList:
                path = iconPath % bridge.name
                try:
                    textureHandle = group.LoadIconTexture(path)
                    if textureHandle > -1:
                        group.SetIconLocation(position, textureHandle, 0, 0, 256, 256)                      # 225 = /128/ | 256 = /256/
                        iconRegistry[bridge.name] = {'path': path, 'exists': 1, 'position': position}
                        position = position + 1
                    else:
                        iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                except:
                    iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                    pass
        else:
            for k, v in iconRegistry:
                textureHandle = group.LoadIconTexture(v['path'])
                group.SetIconLocation(v['position'], textureHandle, 0, 0, 256, 256)                         # 225 = /128/ | 256 = /256/


    def GetQBIcon(bridgeName):
        global iconRegistry

        if not bridgeName:
            return None

        if iconRegistry[bridgeName]['exists']:
            return iconRegistry[bridgeName]['position']
        return None


    def GeneratePlayerBridgeMenu(iShipsUnlocked1):
        global icons, iconsPane
        # Create menus for the player's ship
        # making the bridge menu the slightest bit longer
        pShipMenu = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        iconsPane = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        icons = App.TGIcon_Create(qbIcons, App.SPECIES_UNKNOWN)
        icons.Resize(QB.BRIDGE_MENU_WIDTH, QB.BRIDGE_MENU_HEIGHT)
        RegisterQBIcons()
        App.g_kIconManager.RegisterIconGroup(qbIcons, __name__, "RegisterQBIcons")
        LoadIcon()
        iconsPane.AddChild(icons)

        pStylizedWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize",
                                                       QB.g_pMissionDatabase.GetString("Select Player Bridge"))
        pStylizedWindow.SetUseScrolling(1)

        # making the bridge menu the slightest bit longer
        pStylizedWindow.SetFixedSize(BRIDGE_MENU_WIDTH,
                                     QB.BRIDGE_MENU_HEIGHT)
        pStylizedWindow.SetTitleBarThickness(QB.BAR_HEIGHT)
        pStylizedWindow.AddChild(iconsPane, BRIDGE_MENU_ICON_X_POS)
        pStylizedWindow.AddChild(pShipMenu)
        QB.g_pPlayerPane.AddChild(pStylizedWindow, QB.BRIDGE_MENU_X_POS, QB.BRIDGE_MENU_Y_POS)

        ###############################################################################
        # Dasher42's additions

        QB.bridgeMenuBuilder(QB.qbGameMode.bridgeList, pShipMenu, QB.ET_SELECT_BRIDGE_TYPE, QB.g_pXO)
        pShipMenu.Resize(pShipMenu.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         pShipMenu.GetTotalHeightOfChildren())
        iconsPane.Resize(iconsPane.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         iconsPane.GetTotalHeightOfChildren())
        pStylizedWindow.Layout()
        pStylizedWindow.InteriorChangedSize()

        return pStylizedWindow


    def BuildDialog(bPreservePane=0):
        addHandler = QB.g_bAddedUIHandlers
        originalBuildDialog(bPreservePane)
        if not addHandler:
            QB.g_pXO.AddPythonFuncHandlerForInstance(QB.ET_SELECT_BRIDGE_TYPE, __name__ + ".HandleBridgeIcon")


    def HandleBridgeIcon(pObject, pEvent):
        LoadIcon(Foundation.bridgeList[pEvent.GetInt()].name)
        pObject.CallNextHandler(pEvent)


    def LoadIcon(bridgeName=None):
        global iconRegistry
        if not bridgeName:
            for bridge in Foundation.bridgeList:
                if bridge.bridgeString == QB.g_sBridgeType:
                    bridgeName = bridge.name
                    break
        icon = GetQBIcon(bridgeName)
        if icon:
            icons.SetVisible()
            icons.SetIconNum(icon)
            icons.SizeToArtwork()
        else:
            icons.SetNotVisible()


    class FoundationPreviewPane:
        def __init__(self):
            self.__funcoverride__()

        def __funcoverride__(self):
            QB.REGION_MENU_HEIGHT = REGION_MENU_HEIGHT
            QB.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu
            QB.BuildDialog = BuildDialog
            if menuScrollers:
                menuScrollers.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu


    Foundation.FoundationPreviewPane = FoundationPreviewPane()


Can you fixed the position for the Bridge Icon?

Tomorrow i will Upload a Beta version  :yay:

Test:
https://streamable.com/nqirnj

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Idea: Bridge Preview (concept)
« Reply #16 on: September 30, 2020, 01:30:48 AM »
Another pane needs to be added which overlays the bridge pane but is in a fixed position and is not scrollable. When I have time I'll check it out.
Acta, non verba.
aka USS Sovereign

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.
Re: Idea: Bridge Preview (concept)
« Reply #17 on: October 01, 2020, 07:13:53 AM »
Another pane needs to be added which overlays the bridge pane but is in a fixed position and is not scrollable. When I have time I'll check it out.
thx!

Bridge Preview for Quick Battle

http://www.bc-central.net/forums/index.php/topic,10745.0.html

Offline Mario

  • Senior Software Developer
  • Administrator
  • Posts: 2186
  • Cookies: 1706
  • Life is life
Re: Idea: Bridge Preview (concept)
« Reply #18 on: October 01, 2020, 11:29:36 PM »
Can't say that I agree with 2 different versions. 256x256 should just be a standard then and expected icon size and the graphics should resize itself accordingly to changing game resolutions.

So then:
1. Use 256x256 icons (moved to data\Icons\Bridge\Previews)
2. Bridge preview icon is now "stickied"
3. Bridge icons should resize themselves for appropriate window height, which now they do

Spoiler: show

Code: [Select]
"""Add bridge preview to QB Pane as suggested on the forums"""

import App
import Foundation
import QuickBattle.QuickBattle

menuScrollers = None
try:
    import Custom.Sneaker.MenuScrollers

    menuScrollers = Custom.Sneaker.MenuScrollers
except:
    pass

QB = QuickBattle.QuickBattle
originalBuildDialog = QB.BuildDialog

REGION_MENU_HEIGHT = 0.5475
BRIDGE_MENU_WIDTH = 0.5275
BRIDGE_MENU_ICON_X_POS_OFFSET = 0.30
BRIDGE_MENU_ICON_Y_POS_OFFSET = 0.03
iconRegistry = {}
qbIcons = "QBIcons"
iconPath = "data/Icons/Bridge/Previews/%s.tga"
icons = None
iconsPane = None

if int(Foundation.version[0:8]) >= 20030222:
    print("Adding bridge preview pane...")


    def RegisterQBIcons(group=None):
        global iconRegistry
        if not group:
            group = App.g_kIconManager.CreateIconGroup(qbIcons)
            App.g_kIconManager.AddIconGroup(group)

        if len(iconRegistry) == 0:
            position = 1
            for bridge in Foundation.bridgeList:
                path = iconPath % bridge.name
                try:
                    textureHandle = group.LoadIconTexture(path)
                    if textureHandle > -1:
                        group.SetIconLocation(position, textureHandle, 0, 0, 256, 256)
                        iconRegistry[bridge.name] = {'path': path, 'exists': 1, 'position': position}
                        position = position + 1
                    else:
                        iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                except:
                    iconRegistry[bridge.name] = {'path': path, 'exists': 0, 'position': 0}
                    pass
        else:
            for k, v in iconRegistry:
                if v['exists']:
                    textureHandle = group.LoadIconTexture(v['path'])
                    group.SetIconLocation(v['position'], textureHandle, 0, 0, 256, 256)


    def GetQBIcon(bridgeName):
        global iconRegistry

        if not bridgeName:
            return None

        if iconRegistry[bridgeName]['exists']:
            return iconRegistry[bridgeName]['position']
        return None


    def GeneratePlayerBridgeMenu(iShipsUnlocked1):
        global icons, iconsPane
        # Create menus for the player's ship
        # making the bridge menu the slightest bit longer
        pShipMenu = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         QB.BRIDGE_MENU_HEIGHT, 1)

        iconPaneHeight = QB.BRIDGE_MENU_HEIGHT - BRIDGE_MENU_ICON_Y_POS_OFFSET
        mode = App.GraphicsModeInfo_GetCurrentMode()
        if mode.GetHeight() < 1024:
            iconPaneHeight = iconPaneHeight - (1024.0 / float(mode.GetHeight()) / 100.0)
        iconsPane = App.STSubPane_Create(QB.BRIDGE_MENU_WIDTH,
                                         iconPaneHeight)

        icons = App.TGIcon_Create(qbIcons, App.SPECIES_UNKNOWN)
        icons.Resize(QB.BRIDGE_MENU_WIDTH, iconPaneHeight)
        RegisterQBIcons()
        App.g_kIconManager.RegisterIconGroup(qbIcons, __name__, "RegisterQBIcons")
        iconsPane.AddChild(icons)

        pStylizedWindow = App.STStylizedWindow_CreateW("StylizedWindow", "NoMinimize",
                                                       QB.g_pMissionDatabase.GetString("Select Player Bridge"))
        pStylizedWindow.SetUseScrolling(1)

        # making the bridge menu the slightest bit longer
        pStylizedWindow.SetFixedSize(BRIDGE_MENU_WIDTH,
                                     QB.BRIDGE_MENU_HEIGHT)
        pStylizedWindow.SetTitleBarThickness(QB.BAR_HEIGHT)
        pStylizedWindow.AddChild(pShipMenu)
        QB.g_pPlayerPane.AddChild(pStylizedWindow, QB.BRIDGE_MENU_X_POS, QB.BRIDGE_MENU_Y_POS)
        QB.g_pPlayerPane.AddChild(iconsPane, QB.BRIDGE_MENU_X_POS + BRIDGE_MENU_ICON_X_POS_OFFSET,
                                  QB.BRIDGE_MENU_Y_POS + BRIDGE_MENU_ICON_Y_POS_OFFSET)
        QB.g_pPlayerPane.MoveToFront(iconsPane)

        ###############################################################################
        # Dasher42's additions

        QB.bridgeMenuBuilder(QB.qbGameMode.bridgeList, pShipMenu, QB.ET_SELECT_BRIDGE_TYPE, QB.g_pXO)
        pShipMenu.Resize(pShipMenu.GetWidth() - (BRIDGE_MENU_WIDTH - QB.BRIDGE_MENU_WIDTH),
                         pShipMenu.GetTotalHeightOfChildren())
        iconsPane.Resize(iconsPane.GetWidth(), iconsPane.GetTotalHeightOfChildren())
        pStylizedWindow.Layout()
        pStylizedWindow.InteriorChangedSize()

        # Make sure that everything is stylized before loading bridge icons
        LoadIcon()

        return pStylizedWindow


    def BuildDialog(bPreservePane=0):
        addHandler = QB.g_bAddedUIHandlers
        originalBuildDialog(bPreservePane)
        if not addHandler:
            QB.g_pXO.AddPythonFuncHandlerForInstance(QB.ET_SELECT_BRIDGE_TYPE, __name__ + ".HandleBridgeIcon")


    def HandleBridgeIcon(pObject, pEvent):
        LoadIcon(Foundation.bridgeList[pEvent.GetInt()].name)
        pObject.CallNextHandler(pEvent)


    def LoadIcon(bridgeName=None):
        global iconRegistry
        if not bridgeName:
            for bridge in Foundation.bridgeList:
                if bridge.bridgeString == QB.g_sBridgeType:
                    bridgeName = bridge.name
                    break
        icon = GetQBIcon(bridgeName)
        if icon:
            icons.SetVisible()
            icons.SetIconNum(icon)
            icons.SizeToArtwork()
            if (icons.GetHeight() > iconsPane.GetHeight()):
                ratio = iconsPane.GetHeight() / icons.GetHeight()
                icons.Resize(icons.GetWidth() * ratio, (icons.GetHeight() * ratio) - BRIDGE_MENU_ICON_Y_POS_OFFSET)
        else:
            icons.SetNotVisible()


    class FoundationPreviewPane:
        def __init__(self):
            self.__funcoverride__()

        def __funcoverride__(self):
            QB.REGION_MENU_HEIGHT = REGION_MENU_HEIGHT
            QB.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu
            QB.BuildDialog = BuildDialog
            if menuScrollers:
                menuScrollers.GeneratePlayerBridgeMenu = GeneratePlayerBridgeMenu


    Foundation.FoundationPreviewPane = FoundationPreviewPane()

Acta, non verba.
aka USS Sovereign

Offline Haxxor1337

  • Posts: 83
  • Cookies: 11
    • .~*BC - Galaxy*~.