Перейти к содержимому
Для публикации в этом разделе необходимо провести 50 боёв.
AutoSpy

[ALL] Таймер перезарядки (Reload Timer)

В этой теме 123 комментария

Рекомендуемые комментарии

1 686
[RUSI4]
Мододел, Участник, Коллекционер
2 667 публикаций
25 542 боя
Сегодня в 09:00:30 пользователь PRIMAL_INSTINCT сказал:

Ок, спасибо. Видимо в МОСТе ещё старая версия мода....

МОСТ еще не обновил моды

Ручками поставь

  • Плюс 1

Рассказать о публикации


Ссылка на публикацию
12
[SCAT]
Участник
13 публикаций
1 976 боёв
Сегодня в 12:59:17 пользователь CEJIE3EHb1961 сказал:

Всё ок особо циферки :cap_like:

Можно тут вручную подправить размер? Как по мне через чур уж большие, в старой версии мне нравилось больше.

Если можно ткните пожалуйста в нужную строку.

Скрытый текст

#
# Reload Timer by AutoSpy
#

(def css $ModRTIconRepair ()
    (width=14px)
    (height=16px)
    (marginTop=-2px)
    (backgroundImage='bitmap:icon_repair')
)

(def css $ModRTReloadBarTimeLeft ()
    (flow = "Flow.HORIZONTAL")
    (position = "absolute")
    (top=-12px)
    (width=100%)
    (align = "center|middle")
)

(def constant MOD_RT_RELOAD_TIME_TEXT_COLOR 0xFF4CE8AA)
(def constant MOD_RT_SLOT_RELOAD_FONT_SIZE 38)

(def constant MOD_RT_SLOT_IMG_URL 'url:../battle_hud/weapons_panel/slot/weapon_panel_slot_')

(def constant MOD_RT_WEAPONS_BY_AMMO_TYPE {
            '0':  "SC.Battle.PARAMETER.artilleryReloadTime",
            '2':  "SC.Battle.PARAMETER.torpedoReloadTime",
            '11': "SC.Battle.PARAMETER.air_supportReloadTime"
            }
)

(def macro MOD_RT_BG_IMAGE_BY_STATE (_string:expression, _atWork:expression, _atCharge:expression)
    (block
        (style
            (bind backgroundImage "MOD_RT_SLOT_IMG_URL + _string + (_atWork ? 'green' : _atCharge ? 'blue' : 'orange') + '.png'")
        )
    )
)

(def macro MOD_RT_COUNTDOWN_SCOPE (remainTime:expression)
    (var formatDigitsNumber:number = "remainTime >= 10 ? 0 : 1")
    (var countdownText:str = "countdownFormat(remainTime, formatDigitsNumber, false, false)")
)

(def macro MOD_RT_GET_RELOAD_VALUE_SCOPE (_avatarId:expression=-1, _type:expression=-1)
    (var reloadTimeEntity:gfx = "$datahub.getPrimaryCompositeEntity(CC.parameter, _avatarId, MOD_RT_WEAPONS_BY_AMMO_TYPE[toString(_type)])")
    (var reloadTimeParameter:gfx = "reloadTimeEntity.parameter")
    (var reloadTime:number = "round(reloadTimeParameter.currentValue * 10) / 10" (event "reloadTimeParameter.evChanged"))
    (var reloadTimeText:str = "formatFloatingPoint(reloadTime, 1, false)")
)

(def macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE ()
    (var battleDataEntity:gfx = "$datahub.getSingleEntity(CC.battleData)")
    (var battleState:number = "battleDataEntity.battleState.battleState" (event "battleDataEntity.battleState.evBattleStateChanged"))
    (var battleStarted:bool = "battleState == SC.Common.CLIENT_BATTLE_STATE.STARTED")
)

# orig \gui\unbound2\pc\battle\weapons_panel\slots\slot_renderer.unbound
(def element SlotRenderer (_id:str, _type:number, _count:number)
    (scope
        (event emptyEvent)

        (var selfVehicleWatcher:gfx = "$datahub.getFirstWatcher(CC.selfVehicle)")
        (var selfVehicleEntity:gfx = "selfVehicleWatcher.entity" (event "selfVehicleWatcher.event"))
        (var controller:gfx = "selfVehicleEntity.weaponController" (event "selfVehicleEntity.evAdded") (event "selfVehicleEntity.evRemoved"))
        (var slot:dhEntity = "getPrimaryEntity(CC.weaponSlot, _id)")
        (var isPingerMode:bool = "slot.weaponSlot.isPingerMode && slot.weaponSlot.id == 'torpedo_subdefault_improve'" (event "slot.weaponSlot.evPingerModeChanged"))
        (var pingerEntity:dhEntity = "getPrimaryEntity(CC.gun, SC.Ships.SHIP_WEAPON_TYPES.PINGER)")
        (var pingerState:number = "pingerEntity.gun.state ?: 0" (event "pingerEntity.gun.evStateChanged"))
        (var isPingerCrit:bool = "isIn(pingerState, SC.Weapons.GUN_STATE.CRITICAL_STATES)")
        (var isAirSupport:bool = "slot.weaponSlot.type == SC.Ships.SHIP_WEAPON_TYPES.AIR_SUPPORT")

        (var slotOptions:dhComponent = "slot ? slot.slotOptions : null" (event "slot.evAdded") (event "slot.evRemoved"))
        (var state:number = "slot ? slot.weaponSlot.state : 0" (event "slot.weaponSlot.evStateChanged"))

        (var visualSlotDataEntity:gfx = "$datahub.getPrimaryEntity(CC.visualSlotData, tr(slot.weaponSlot.id) + '_' + DEFAULT_AVATAR_ID)")
        (var isAutoUsage:bool = "visualSlotDataEntity ? visualSlotDataEntity.visualSlotData.commandId == CMD_AUTO : false")
        (var squadId:number = "visualSlotDataEntity ? visualSlotDataEntity.visualSlotData.squadId : -1")
        (var ownerEntity:gfx = "_type == SC.Ships.SHIP_WEAPON_TYPES.AIRPLANES ?  $datahub.getPrimaryEntity(CC.ownSquadron, squadId) : $datahub.getSingleEntity(CC.playerAvatar)")

        (var drumFireModeEntity:gfx = "$datahub.getSingleEntity(CC.drumFireMode)")
        (var drumFireModeComponent:gfx = "drumFireModeEntity.drumFireMode")
        (var isDrumFireModeActive:bool = "drumFireModeComponent.isActive" (event "drumFireModeComponent.evIsActiveChanged"))
        (var isCanDrum:bool = "drumFireModeComponent && _type == SC.Ships.SHIP_WEAPON_TYPES.ARTILLERY")
        (var isActiveDrum:bool = "isCanDrum && isDrumFireModeActive")

        (var status:str = "(isPingerMode && isPingerCrit) || isIn(state, SC.Weapons.GUN_STATE.CRITICAL_STATES) ? '_disabled'
                                                                                             : ''" (event "slot.weaponSlot.evStateChanged"))

        (var critModulePrefix:str = "isPingerMode ? isPingerCrit && isIn(state, SC.Weapons.GUN_STATE.CRITICAL_STATES)    ? '_all' :
                                                                                                         isPingerCrit    ? '_ping'
                                                                                                                         : ''
                                                     : ''" (event "slot.weaponSlot.evPingerModeChanged"))

        (var icon:str = "'url:../consumables/ammo_' + slot.weaponSlot.id + critModulePrefix + status + '.png'")

        (var command:number = "slot.weaponSlot.command")

        (var animationProgress:number=1)
        (var isAnimated:bool = "animationProgress < 1")

        (var _width:number = "SLOT_SIZE")
        (var _height:number = "SLOT_SIZE")
        (var isWeaponActive:bool = "controller ? (controller.selectedWeapon == _type) : false" (event "controller.evSelectedWeaponChanged"))
        (var isActive:bool = "slot.weaponSlot.active" (event "slot.weaponSlot.evActiveChanged"))
        (var isSelected:bool = "slot.weaponSlot.selected" (event "slot.weaponSlot.evSelectedChanged"))
        (var isAlive:bool = "isPingerMode ? pingerState < SC.Weapons.GUN_STATE.CRITICAL : state < SC.Weapons.GUN_STATE.CRITICAL")
        (var isWorking:bool = "state == SC.Weapons.GUN_STATE.WORK")
        (var isReloading:bool = "state == SC.Weapons.GUN_STATE.RELOAD")
        (var isCharging:bool = "state == SC.Weapons.GUN_STATE.CHARGE")
        (var isDisabled:bool = "state == SC.Weapons.GUN_STATE.DISABLED")
        (var isAngleVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.TORPEDO_ANGLE_SELECTION")
        (var isSelectorType:bool = "slotOptions && isIn(slotOptions.type, SC.Battle.SLOT_VISUALIZATION_TYPE.SLOT_ADDITIONAL_VISUALS)")
        (var isSelectorVisible:bool = "isSelectorType && slotOptions.showItemsSelector && (slotOptions.items.length > 1)")
        (var isAirplanesVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.AIRPLANES")
        (var isSerialLoaderVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.SERIAL_LOADER")

        (var isPingerType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.PINGER_ACTIVE_COUNT")
        (var shipTTX:gfx = "selfVehicleEntity.selfVehicle.shipTTX")
        (var isPingerCountEnable:bool = "isPingerType && (shipTTX ? shipTTX.pinger.maxTargets.value > 0 : false)")

        (var cameraEntity:gfx = "$datahub.getSingleEntity(CC.camera)")
        (struct altVisionMode = GET_PREF_STR(_option = "'battle.altVision.mode'"))
        (var isAltVision:bool = "cameraEntity.camera.altVision || AltVisionMode[altVisionMode.value] >= AltVisionMode.ADAPTIVE" (event "cameraEntity.camera.evAltVisionChanged"))

        (var optionsCommandId:number = "slotOptions ? slotOptions.commandId : Cmd.CMD_NONE")
        (var isHotKeyActive:bool = "(isSelected || isActive) && isWeaponActive")
        (var isHotKeyEnabled:bool = "command && !isAutoUsage")
        (var isHotKeyToggled:bool = "isActive && isWeaponActive")

        (var progressComponent:dhComponent = "isPingerMode ? pingerEntity.progress : slot.progress")
        (var progress:number = "isPingerMode && !isAlive     ? 0 :
                                 progressComponent.max != 0  ? 1 - progressComponent.value / progressComponent.max
                                                             : 0" (event "progressComponent.evChanged"))
        (var remain:number = "isWorking ? progressComponent.value : progressComponent.max - progressComponent.value" (event "progressComponent.evChanged"))

        (var showProgressBar:bool = "(isActive || isAirplanesVisType || isAirSupport) && (progress > 0)")

        (macro MOD_RT_GET_RELOAD_VALUE_SCOPE "ownerEntity.id" "_type") # return reloadTime
        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)

        (controller $Animation
            (bindcall play
                duration=0.1
                delay=0
                from = "{progress: 0, animationProgress: 0}"
                to = "{progress: 1, animationProgress: 1}"
                (event "slot.weaponSlot.evCharged")
            )
        )

        (var slotAlpha:number = "(isActive || (isWeaponActive && isSelected) || isAirplanesVisType) ? 1 : 0.7")

        (macro STAGE_SIZE)
    )

    (style
        (flow = "Flow.HORIZONTAL")
        (marginRight = "PANEL_ITEM_MARGIN")
        (backgroundColor = "SC.Ui_styles.SERVICE_COLORS.INNER_PANEL")
    )

    (bind name "'button_ammo_' + _id")

    (controller $Instance renderer='AngleSwitcher'
        (bind enabled "isSelectorVisible")
        (args _command="slotOptions ? slotOptions.commandId : Cmd.CMD_NONE")
        (exprs
            (scope
                (bind _selected "toNumber(slotOptions && slotOptions.selected)" (event "slotOptions.evSelectedChanged"))
                (bind _options "slotOptions ? slotOptions.items : []")
            )
        )
    )

    (controller $Instance renderer='SerialLoaderInfo'
        (bind enabled "isSerialLoaderVisType")
        (args "_type")
    )

    (block
        (bind name "(isActive && isWeaponActive) ? 'selected' : 'not_selected'")

        (block
            (bind alpha "slotAlpha")
            (element SlotItem
                _itemImageUrl         = "icon"
                _isSelectable         = "!isAutoUsage"
                _width                 = "_width"
                _height             = "_height"
                _isLocked             = "isDisabled"
                _selectedImageUrl     = "isCharging || isAnimated ? 'url:../battle_hud/weapons_panel/slot/weapon_panel_slot_stroke_blue.png' : ''"
                _isPreSelected         = "isWeaponActive && isSelected"
                _isSelected         = "isWeaponActive && isActive"
                _isActiveDrum         = "isActiveDrum"
            )
        )

        (controller $Instance renderer='PingerCountInfoRenderer'
            (bind enabled "isPingerCountEnable")
            (exprs
                (style (position = "absolute"))
                (bind visible "isAltVision")
            )
        )

        (block
            (bind visible "!showProgressBar && (reloadTime > 0) && (status == '')")

            (class $FullsizeAbsolute)
            (style (align = "center|middle") (hitTest=false))

            (tf
                (class $ActionPanelTimerCountdown)
                (style
                    (fontSize = "MOD_RT_SLOT_RELOAD_FONT_SIZE")
                    (bind textColor "battleStarted ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
                )

                (bind text "reloadTime < 10 ? reloadTimeText : round(reloadTime)")
            )
        )

        (element SlotReloadBar
            (bind visible "showProgressBar && (!(isPingerCountEnable) || !isAltVision)")
            (scope
                (bind _atWork "isWorking")
                (bind _atCharge "isCharging || isAnimated")
                (bind _inverted "false")
                (bind _showTime "!isAnimated")
                (bind _percentPassed "progress ?: 0")
                (bind _remainTime "remain ?: 0")
            )

            (class $FullsizeAbsolute)
        )

        (controller $FxInstance lifetime=0.5
            (renderer = 'SlotWorkStartedFX')
            (args
                accented = "!isWeaponActive"
            )
            (bindcall create (event "slot.weaponSlot.evReloaded") (bind enabled "isActive && !isAirplanesVisType"))
        )

        (controller $Instance renderer='HotkeyIndicator'
            (bind enabled "isHotKeyEnabled")
            (args
                _commandId     = "command"
                _toggled     = "isHotKeyToggled"
                _active     = "isHotKeyActive"
            )
            (exprs
                (style
                    (bottom = "-HOTKEY_SIZE[SIZE.MEDIUM] - PANEL_HOTKEY_GAP")
                    (hitTest=false)
                    (position = "absolute")
                    (hcenter=0px)
                )
            )
        )

        (controller $Instance renderer='LabelAuto'
            (bind enabled "isAutoUsage")
        )

        (controller $Instance renderer='PlaneReloadProgressAndAttackersBarSlot'
            (bind enabled "isAirplanesVisType")
            (args "slot.weaponSlot.rawIndex" "!showProgressBar")
        )

        (block
            (class $FullsizeAbsolute)
            (style (backgroundColor = "NO_COLOR"))

            (macro MOUSE_LMB_EXTERNAL_CALL 'direct.action' "['weaponSlot.pressed', [command]]" "isHotKeyEnabled")

            (controller $Tooltip
                (renderer='BattleWeaponTooltip')
                (args
                    _ammoType         = "slot.weaponSlot.id"
                    _entityId         = "ownerEntity.id"
                    _isActiveDrum     = "isActiveDrum"
                )
                (align = "bottom|center")
                (position = "border")
                (offset = [0, 20])
                (screenBoundsOffset = {left:10, top:30, right:10, bottom:100})
                (macro SIMPLE_TOOLTIP_ANIMATION)
            )
        )
    )
)

# orig \gui\unbound2\pc\battle\weapons_panel\slots\fx\slot_reload_bar.unbound
(def element SlotReloadBar ()
    (scope
        (var _reloadEntityId:number = -1)
        (var _atWork:bool = false)
        (var _atCharge:bool = false)
        (var _inverted:bool = true)
        (var _remainTime:number = 0)
        (var _showTime:bool = true)
        (var _percentPassed:number = 0)

        (macro MOD_RT_COUNTDOWN_SCOPE "_remainTime")

        (var fxMargins:number = "(SLOT_FX_SIZE - SLOT_SIZE) / 2")

        (var percentPassed:number = "abs((_atWork && _inverted ? 0 : 1) - _percentPassed)")
        (var progress:number = "percentPassed")
        (var curMaskY:number = "SLOT_SIZE * (1 - progress)")
    )

    (style
        (position = "absolute")
        (top = "-fxMargins")
        (left = "-fxMargins")
        (align = "center|middle")
        (width = "SLOT_FX_SIZE")
        (height = "SLOT_FX_SIZE")
    )

    (block
        (class $FullsizeAbsolute)
        (style
            (backgroundImage = "MOD_RT_SLOT_IMG_URL + 'bg.png'")
        )
    )

    (block
        (style
            (position = "absolute")
            (width = "SLOT_SIZE")
            (height = "SLOT_SIZE")
            (top = "fxMargins")
            (left = "fxMargins")
        )

        (block
            (style
                (position = "absolute")
                (top = "-fxMargins")
                (left = "-fxMargins")
            )

            (macro MOD_RT_BG_IMAGE_BY_STATE "'tint_'" "_atWork" "_atCharge")
        )

        (block
            (style
                (position = "absolute")
                (left = "-fxMargins")
                (bind top "curMaskY")
            )

            (macro MOD_RT_BG_IMAGE_BY_STATE "'bar_'" "_atWork" "_atCharge")
        )

        (block
            (class $FullsizeAbsolute)
            (style
                (bind top "curMaskY")
                (backgroundColor = "SC.Ui_styles.SERVICE_COLORS.BLACK")
            )
            (isMask=true)
        )
    )

    (tf
        (bind visible "_showTime")

        (class $ActionPanelTimerCountdown)
        (style
            (fontSize = "MOD_RT_SLOT_RELOAD_FONT_SIZE")
            (bind textColor "    _atWork        ? C_ACTIVE :
                                _atCharge    ? 0xFF07CEFA
                                            : C_RELOAD")
        )

        (macro TFMouseEnabled value=false)

        (bind text "countdownText")
    )
)

# orig \gui\unbound2\pc\battle\reload_bar\guns_reload_bar.unbound
(def element ReloadBarTimeLeft (_gunEntityId:number, _mostReadyId:number = 0) layout=true
    (scope
        (var gunEntity:gfx = "$datahub.getEntity(_gunEntityId)")
        (var gunComponent:gfx = "gunEntity ? gunEntity.gun : null")
        (var gunType:number = "gunComponent ? gunComponent.type : SC.Ships.SHIP_WEAPON_TYPES.NONE")
        (var gunHealthState:number = "gunComponent.status" (event "gunComponent.evStatusChanged"))
        (var gunState:number = "gunComponent.state" (event "gunComponent.evStateChanged"))

        (var isReady:bool = "gunState == SC.Weapons.GUN_STATE.READY")
        (var isWorking:bool = "gunState == SC.Weapons.GUN_STATE.WORK")
        (var isCrit:bool = "gunHealthState == SC.Battle.MODULES_STATES.CRIT")
        (var isNotSwitchingCritical:bool = "gunState != SC.Weapons.GUN_STATE.SWITCHING_CRITICAL")
        (var isNotSwitchingCriticalAndIsCrit:bool = "isCrit && isNotSwitchingCritical")

        (var barrelShotMode:bool = "gunEntity.barrelsModifier && gunEntity.barrelsModifier.mode == SC.Weapons.BARREL_FIRE_MODE.SINGLE" (event "gunEntity.barrelsModifier.evModeChanged"))
        (var isBetweenShots:bool = "gunEntity.barrelsModifier.isBetweenShots" (event "gunEntity.barrelsModifier.evBetweenShotsChanged"))

        (var gunBarrelEntity:gfx = "$datahub.getEntity(_mostReadyId)")
        (var isBarrelCharging:bool = "gunBarrelEntity.gunBarrel.isCharging" (event "gunBarrelEntity.gunBarrel.evChanged"))

        (var isBarrelProgress:bool = "barrelShotMode && !isCrit && (isBarrelCharging || isBetweenShots)")

        (var progressComponent:gfx = "isBarrelProgress ? gunBarrelEntity.progress : gunEntity.progress" (event "gunEntity.evAdded") (event "gunEntity.evRemoved"))

        (var progressMax:number = "progressComponent ? progressComponent.max : 1" (event "progressComponent.evChanged"))
        (var progressTime:number = "progressComponent ? progressComponent.value : 0" (event "progressComponent.evChanged"))

        (var remainTime:number = "(progressComponent && !isWorking)
                                        ? isNotSwitchingCriticalAndIsCrit
                                            ? progressTime
                                            : (progressMax - progressTime)
                                        : 0" (event "progressComponent.evChanged"))

        (var hasRemainTime:bool = "remainTime > 0")

        (macro MOD_RT_COUNTDOWN_SCOPE "remainTime")

        (var avatar:gfx = "$datahub.getSingleEntity(CC.playerAvatar)")

        (macro MOD_RT_GET_RELOAD_VALUE_SCOPE "avatar.id" "gunType") # return reloadTime

        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)
    )

    (class $ModRTReloadBarTimeLeft)

    (block
        (bind visible "isNotSwitchingCriticalAndIsCrit")

        (class $ModRTIconRepair)
    )

    (tf
        (class $TextDefaultNM)
        (class $FontEnableReadability)
        (style
            (alpha=0.9)
            (bind textColor "(isReady && battleStarted) ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
        )

        (bind text "hasRemainTime ? countdownText : (reloadTime > 0 ? reloadTimeText : '')")
    )
)

# orig \gui\unbound2\pc\battle\reload_bar\guns_reload_bar.unbound
(def element SerialReloadBarTimeLeft (_reloadBarState:number, _progressEntityId:number) layout=true
    (scope
        (var progressComponent:gfx = "$datahub.getEntity(_progressEntityId).progress")
        (var progressMax:number = "progressComponent ? progressComponent.max : 1" (event "progressComponent.evChanged"))
        (var progressTime:number = "progressComponent ? progressComponent.value : 0" (event "progressComponent.evChanged"))

        (var isReady:bool = "_reloadBarState == ReloadBarState.NORMAL")
        (var isCrit:bool = "_reloadBarState == ReloadBarState.CRIT")

        (var remainTime:number = "progressComponent    ? isCrit    ? progressTime
                                                                : progressMax - progressTime
                                                    : 0")
        (var hasRemainTime:bool = "remainTime > 0")

        (macro MOD_RT_COUNTDOWN_SCOPE "remainTime")

        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)
    )

    (class $ModRTReloadBarTimeLeft)

    (block
        (bind visible "isCrit")

        (class $ModRTIconRepair)
    )

    (tf
        (class $TextDefaultNM)
        (class $FontEnableReadability)
        (style
            (alpha=0.9)
            (bind textColor "(isReady && battleStarted) ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
        )

        (bind text "hasRemainTime ? countdownText : (progressMax > 0 ? formatFloatingPoint(progressMax, 1, false) : '')")
    )
)
 

 

Рассказать о публикации


Ссылка на публикацию
5 821
[MRDRS]
Мододел
3 157 публикаций
1 615 боёв
Сегодня в 10:21:38 пользователь PRIMAL_INSTINCT сказал:

Можно тут вручную подправить размер? Как по мне через чур уж большие, в старой версии мне нравилось больше.

Если можно ткните пожалуйста в нужную строку.

  Показать содержимое

#
# Reload Timer by AutoSpy
#

(def css $ModRTIconRepair ()
    (width=14px)
    (height=16px)
    (marginTop=-2px)
    (backgroundImage='bitmap:icon_repair')
)

(def css $ModRTReloadBarTimeLeft ()
    (flow = "Flow.HORIZONTAL")
    (position = "absolute")
    (top=-12px)
    (width=100%)
    (align = "center|middle")
)

(def constant MOD_RT_RELOAD_TIME_TEXT_COLOR 0xFF4CE8AA)
(def constant MOD_RT_SLOT_RELOAD_FONT_SIZE 38)

(def constant MOD_RT_SLOT_IMG_URL 'url:../battle_hud/weapons_panel/slot/weapon_panel_slot_')

(def constant MOD_RT_WEAPONS_BY_AMMO_TYPE {
            '0':  "SC.Battle.PARAMETER.artilleryReloadTime",
            '2':  "SC.Battle.PARAMETER.torpedoReloadTime",
            '11': "SC.Battle.PARAMETER.air_supportReloadTime"
            }
)

(def macro MOD_RT_BG_IMAGE_BY_STATE (_string:expression, _atWork:expression, _atCharge:expression)
    (block
        (style
            (bind backgroundImage "MOD_RT_SLOT_IMG_URL + _string + (_atWork ? 'green' : _atCharge ? 'blue' : 'orange') + '.png'")
        )
    )
)

(def macro MOD_RT_COUNTDOWN_SCOPE (remainTime:expression)
    (var formatDigitsNumber:number = "remainTime >= 10 ? 0 : 1")
    (var countdownText:str = "countdownFormat(remainTime, formatDigitsNumber, false, false)")
)

(def macro MOD_RT_GET_RELOAD_VALUE_SCOPE (_avatarId:expression=-1, _type:expression=-1)
    (var reloadTimeEntity:gfx = "$datahub.getPrimaryCompositeEntity(CC.parameter, _avatarId, MOD_RT_WEAPONS_BY_AMMO_TYPE[toString(_type)])")
    (var reloadTimeParameter:gfx = "reloadTimeEntity.parameter")
    (var reloadTime:number = "round(reloadTimeParameter.currentValue * 10) / 10" (event "reloadTimeParameter.evChanged"))
    (var reloadTimeText:str = "formatFloatingPoint(reloadTime, 1, false)")
)

(def macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE ()
    (var battleDataEntity:gfx = "$datahub.getSingleEntity(CC.battleData)")
    (var battleState:number = "battleDataEntity.battleState.battleState" (event "battleDataEntity.battleState.evBattleStateChanged"))
    (var battleStarted:bool = "battleState == SC.Common.CLIENT_BATTLE_STATE.STARTED")
)

# orig \gui\unbound2\pc\battle\weapons_panel\slots\slot_renderer.unbound
(def element SlotRenderer (_id:str, _type:number, _count:number)
    (scope
        (event emptyEvent)

        (var selfVehicleWatcher:gfx = "$datahub.getFirstWatcher(CC.selfVehicle)")
        (var selfVehicleEntity:gfx = "selfVehicleWatcher.entity" (event "selfVehicleWatcher.event"))
        (var controller:gfx = "selfVehicleEntity.weaponController" (event "selfVehicleEntity.evAdded") (event "selfVehicleEntity.evRemoved"))
        (var slot:dhEntity = "getPrimaryEntity(CC.weaponSlot, _id)")
        (var isPingerMode:bool = "slot.weaponSlot.isPingerMode && slot.weaponSlot.id == 'torpedo_subdefault_improve'" (event "slot.weaponSlot.evPingerModeChanged"))
        (var pingerEntity:dhEntity = "getPrimaryEntity(CC.gun, SC.Ships.SHIP_WEAPON_TYPES.PINGER)")
        (var pingerState:number = "pingerEntity.gun.state ?: 0" (event "pingerEntity.gun.evStateChanged"))
        (var isPingerCrit:bool = "isIn(pingerState, SC.Weapons.GUN_STATE.CRITICAL_STATES)")
        (var isAirSupport:bool = "slot.weaponSlot.type == SC.Ships.SHIP_WEAPON_TYPES.AIR_SUPPORT")

        (var slotOptions:dhComponent = "slot ? slot.slotOptions : null" (event "slot.evAdded") (event "slot.evRemoved"))
        (var state:number = "slot ? slot.weaponSlot.state : 0" (event "slot.weaponSlot.evStateChanged"))

        (var visualSlotDataEntity:gfx = "$datahub.getPrimaryEntity(CC.visualSlotData, tr(slot.weaponSlot.id) + '_' + DEFAULT_AVATAR_ID)")
        (var isAutoUsage:bool = "visualSlotDataEntity ? visualSlotDataEntity.visualSlotData.commandId == CMD_AUTO : false")
        (var squadId:number = "visualSlotDataEntity ? visualSlotDataEntity.visualSlotData.squadId : -1")
        (var ownerEntity:gfx = "_type == SC.Ships.SHIP_WEAPON_TYPES.AIRPLANES ?  $datahub.getPrimaryEntity(CC.ownSquadron, squadId) : $datahub.getSingleEntity(CC.playerAvatar)")

        (var drumFireModeEntity:gfx = "$datahub.getSingleEntity(CC.drumFireMode)")
        (var drumFireModeComponent:gfx = "drumFireModeEntity.drumFireMode")
        (var isDrumFireModeActive:bool = "drumFireModeComponent.isActive" (event "drumFireModeComponent.evIsActiveChanged"))
        (var isCanDrum:bool = "drumFireModeComponent && _type == SC.Ships.SHIP_WEAPON_TYPES.ARTILLERY")
        (var isActiveDrum:bool = "isCanDrum && isDrumFireModeActive")

        (var status:str = "(isPingerMode && isPingerCrit) || isIn(state, SC.Weapons.GUN_STATE.CRITICAL_STATES) ? '_disabled'
                                                                                             : ''" (event "slot.weaponSlot.evStateChanged"))

        (var critModulePrefix:str = "isPingerMode ? isPingerCrit && isIn(state, SC.Weapons.GUN_STATE.CRITICAL_STATES)    ? '_all' :
                                                                                                         isPingerCrit    ? '_ping'
                                                                                                                         : ''
                                                     : ''" (event "slot.weaponSlot.evPingerModeChanged"))

        (var icon:str = "'url:../consumables/ammo_' + slot.weaponSlot.id + critModulePrefix + status + '.png'")

        (var command:number = "slot.weaponSlot.command")

        (var animationProgress:number=1)
        (var isAnimated:bool = "animationProgress < 1")

        (var _width:number = "SLOT_SIZE")
        (var _height:number = "SLOT_SIZE")
        (var isWeaponActive:bool = "controller ? (controller.selectedWeapon == _type) : false" (event "controller.evSelectedWeaponChanged"))
        (var isActive:bool = "slot.weaponSlot.active" (event "slot.weaponSlot.evActiveChanged"))
        (var isSelected:bool = "slot.weaponSlot.selected" (event "slot.weaponSlot.evSelectedChanged"))
        (var isAlive:bool = "isPingerMode ? pingerState < SC.Weapons.GUN_STATE.CRITICAL : state < SC.Weapons.GUN_STATE.CRITICAL")
        (var isWorking:bool = "state == SC.Weapons.GUN_STATE.WORK")
        (var isReloading:bool = "state == SC.Weapons.GUN_STATE.RELOAD")
        (var isCharging:bool = "state == SC.Weapons.GUN_STATE.CHARGE")
        (var isDisabled:bool = "state == SC.Weapons.GUN_STATE.DISABLED")
        (var isAngleVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.TORPEDO_ANGLE_SELECTION")
        (var isSelectorType:bool = "slotOptions && isIn(slotOptions.type, SC.Battle.SLOT_VISUALIZATION_TYPE.SLOT_ADDITIONAL_VISUALS)")
        (var isSelectorVisible:bool = "isSelectorType && slotOptions.showItemsSelector && (slotOptions.items.length > 1)")
        (var isAirplanesVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.AIRPLANES")
        (var isSerialLoaderVisType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.SERIAL_LOADER")

        (var isPingerType:bool = "slotOptions && slotOptions.type == SC.Battle.SLOT_VISUALIZATION_TYPE.PINGER_ACTIVE_COUNT")
        (var shipTTX:gfx = "selfVehicleEntity.selfVehicle.shipTTX")
        (var isPingerCountEnable:bool = "isPingerType && (shipTTX ? shipTTX.pinger.maxTargets.value > 0 : false)")

        (var cameraEntity:gfx = "$datahub.getSingleEntity(CC.camera)")
        (struct altVisionMode = GET_PREF_STR(_option = "'battle.altVision.mode'"))
        (var isAltVision:bool = "cameraEntity.camera.altVision || AltVisionMode[altVisionMode.value] >= AltVisionMode.ADAPTIVE" (event "cameraEntity.camera.evAltVisionChanged"))

        (var optionsCommandId:number = "slotOptions ? slotOptions.commandId : Cmd.CMD_NONE")
        (var isHotKeyActive:bool = "(isSelected || isActive) && isWeaponActive")
        (var isHotKeyEnabled:bool = "command && !isAutoUsage")
        (var isHotKeyToggled:bool = "isActive && isWeaponActive")

        (var progressComponent:dhComponent = "isPingerMode ? pingerEntity.progress : slot.progress")
        (var progress:number = "isPingerMode && !isAlive     ? 0 :
                                 progressComponent.max != 0  ? 1 - progressComponent.value / progressComponent.max
                                                             : 0" (event "progressComponent.evChanged"))
        (var remain:number = "isWorking ? progressComponent.value : progressComponent.max - progressComponent.value" (event "progressComponent.evChanged"))

        (var showProgressBar:bool = "(isActive || isAirplanesVisType || isAirSupport) && (progress > 0)")

        (macro MOD_RT_GET_RELOAD_VALUE_SCOPE "ownerEntity.id" "_type") # return reloadTime
        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)

        (controller $Animation
            (bindcall play
                duration=0.1
                delay=0
                from = "{progress: 0, animationProgress: 0}"
                to = "{progress: 1, animationProgress: 1}"
                (event "slot.weaponSlot.evCharged")
            )
        )

        (var slotAlpha:number = "(isActive || (isWeaponActive && isSelected) || isAirplanesVisType) ? 1 : 0.7")

        (macro STAGE_SIZE)
    )

    (style
        (flow = "Flow.HORIZONTAL")
        (marginRight = "PANEL_ITEM_MARGIN")
        (backgroundColor = "SC.Ui_styles.SERVICE_COLORS.INNER_PANEL")
    )

    (bind name "'button_ammo_' + _id")

    (controller $Instance renderer='AngleSwitcher'
        (bind enabled "isSelectorVisible")
        (args _command="slotOptions ? slotOptions.commandId : Cmd.CMD_NONE")
        (exprs
            (scope
                (bind _selected "toNumber(slotOptions && slotOptions.selected)" (event "slotOptions.evSelectedChanged"))
                (bind _options "slotOptions ? slotOptions.items : []")
            )
        )
    )

    (controller $Instance renderer='SerialLoaderInfo'
        (bind enabled "isSerialLoaderVisType")
        (args "_type")
    )

    (block
        (bind name "(isActive && isWeaponActive) ? 'selected' : 'not_selected'")

        (block
            (bind alpha "slotAlpha")
            (element SlotItem
                _itemImageUrl         = "icon"
                _isSelectable         = "!isAutoUsage"
                _width                 = "_width"
                _height             = "_height"
                _isLocked             = "isDisabled"
                _selectedImageUrl     = "isCharging || isAnimated ? 'url:../battle_hud/weapons_panel/slot/weapon_panel_slot_stroke_blue.png' : ''"
                _isPreSelected         = "isWeaponActive && isSelected"
                _isSelected         = "isWeaponActive && isActive"
                _isActiveDrum         = "isActiveDrum"
            )
        )

        (controller $Instance renderer='PingerCountInfoRenderer'
            (bind enabled "isPingerCountEnable")
            (exprs
                (style (position = "absolute"))
                (bind visible "isAltVision")
            )
        )

        (block
            (bind visible "!showProgressBar && (reloadTime > 0) && (status == '')")

            (class $FullsizeAbsolute)
            (style (align = "center|middle") (hitTest=false))

            (tf
                (class $ActionPanelTimerCountdown)
                (style
                    (fontSize = "MOD_RT_SLOT_RELOAD_FONT_SIZE")
                    (bind textColor "battleStarted ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
                )

                (bind text "reloadTime < 10 ? reloadTimeText : round(reloadTime)")
            )
        )

        (element SlotReloadBar
            (bind visible "showProgressBar && (!(isPingerCountEnable) || !isAltVision)")
            (scope
                (bind _atWork "isWorking")
                (bind _atCharge "isCharging || isAnimated")
                (bind _inverted "false")
                (bind _showTime "!isAnimated")
                (bind _percentPassed "progress ?: 0")
                (bind _remainTime "remain ?: 0")
            )

            (class $FullsizeAbsolute)
        )

        (controller $FxInstance lifetime=0.5
            (renderer = 'SlotWorkStartedFX')
            (args
                accented = "!isWeaponActive"
            )
            (bindcall create (event "slot.weaponSlot.evReloaded") (bind enabled "isActive && !isAirplanesVisType"))
        )

        (controller $Instance renderer='HotkeyIndicator'
            (bind enabled "isHotKeyEnabled")
            (args
                _commandId     = "command"
                _toggled     = "isHotKeyToggled"
                _active     = "isHotKeyActive"
            )
            (exprs
                (style
                    (bottom = "-HOTKEY_SIZE[SIZE.MEDIUM] - PANEL_HOTKEY_GAP")
                    (hitTest=false)
                    (position = "absolute")
                    (hcenter=0px)
                )
            )
        )

        (controller $Instance renderer='LabelAuto'
            (bind enabled "isAutoUsage")
        )

        (controller $Instance renderer='PlaneReloadProgressAndAttackersBarSlot'
            (bind enabled "isAirplanesVisType")
            (args "slot.weaponSlot.rawIndex" "!showProgressBar")
        )

        (block
            (class $FullsizeAbsolute)
            (style (backgroundColor = "NO_COLOR"))

            (macro MOUSE_LMB_EXTERNAL_CALL 'direct.action' "['weaponSlot.pressed', [command]]" "isHotKeyEnabled")

            (controller $Tooltip
                (renderer='BattleWeaponTooltip')
                (args
                    _ammoType         = "slot.weaponSlot.id"
                    _entityId         = "ownerEntity.id"
                    _isActiveDrum     = "isActiveDrum"
                )
                (align = "bottom|center")
                (position = "border")
                (offset = [0, 20])
                (screenBoundsOffset = {left:10, top:30, right:10, bottom:100})
                (macro SIMPLE_TOOLTIP_ANIMATION)
            )
        )
    )
)

# orig \gui\unbound2\pc\battle\weapons_panel\slots\fx\slot_reload_bar.unbound
(def element SlotReloadBar ()
    (scope
        (var _reloadEntityId:number = -1)
        (var _atWork:bool = false)
        (var _atCharge:bool = false)
        (var _inverted:bool = true)
        (var _remainTime:number = 0)
        (var _showTime:bool = true)
        (var _percentPassed:number = 0)

        (macro MOD_RT_COUNTDOWN_SCOPE "_remainTime")

        (var fxMargins:number = "(SLOT_FX_SIZE - SLOT_SIZE) / 2")

        (var percentPassed:number = "abs((_atWork && _inverted ? 0 : 1) - _percentPassed)")
        (var progress:number = "percentPassed")
        (var curMaskY:number = "SLOT_SIZE * (1 - progress)")
    )

    (style
        (position = "absolute")
        (top = "-fxMargins")
        (left = "-fxMargins")
        (align = "center|middle")
        (width = "SLOT_FX_SIZE")
        (height = "SLOT_FX_SIZE")
    )

    (block
        (class $FullsizeAbsolute)
        (style
            (backgroundImage = "MOD_RT_SLOT_IMG_URL + 'bg.png'")
        )
    )

    (block
        (style
            (position = "absolute")
            (width = "SLOT_SIZE")
            (height = "SLOT_SIZE")
            (top = "fxMargins")
            (left = "fxMargins")
        )

        (block
            (style
                (position = "absolute")
                (top = "-fxMargins")
                (left = "-fxMargins")
            )

            (macro MOD_RT_BG_IMAGE_BY_STATE "'tint_'" "_atWork" "_atCharge")
        )

        (block
            (style
                (position = "absolute")
                (left = "-fxMargins")
                (bind top "curMaskY")
            )

            (macro MOD_RT_BG_IMAGE_BY_STATE "'bar_'" "_atWork" "_atCharge")
        )

        (block
            (class $FullsizeAbsolute)
            (style
                (bind top "curMaskY")
                (backgroundColor = "SC.Ui_styles.SERVICE_COLORS.BLACK")
            )
            (isMask=true)
        )
    )

    (tf
        (bind visible "_showTime")

        (class $ActionPanelTimerCountdown)
        (style
            (fontSize = "MOD_RT_SLOT_RELOAD_FONT_SIZE")
            (bind textColor "    _atWork        ? C_ACTIVE :
                                _atCharge    ? 0xFF07CEFA
                                            : C_RELOAD")
        )

        (macro TFMouseEnabled value=false)

        (bind text "countdownText")
    )
)

# orig \gui\unbound2\pc\battle\reload_bar\guns_reload_bar.unbound
(def element ReloadBarTimeLeft (_gunEntityId:number, _mostReadyId:number = 0) layout=true
    (scope
        (var gunEntity:gfx = "$datahub.getEntity(_gunEntityId)")
        (var gunComponent:gfx = "gunEntity ? gunEntity.gun : null")
        (var gunType:number = "gunComponent ? gunComponent.type : SC.Ships.SHIP_WEAPON_TYPES.NONE")
        (var gunHealthState:number = "gunComponent.status" (event "gunComponent.evStatusChanged"))
        (var gunState:number = "gunComponent.state" (event "gunComponent.evStateChanged"))

        (var isReady:bool = "gunState == SC.Weapons.GUN_STATE.READY")
        (var isWorking:bool = "gunState == SC.Weapons.GUN_STATE.WORK")
        (var isCrit:bool = "gunHealthState == SC.Battle.MODULES_STATES.CRIT")
        (var isNotSwitchingCritical:bool = "gunState != SC.Weapons.GUN_STATE.SWITCHING_CRITICAL")
        (var isNotSwitchingCriticalAndIsCrit:bool = "isCrit && isNotSwitchingCritical")

        (var barrelShotMode:bool = "gunEntity.barrelsModifier && gunEntity.barrelsModifier.mode == SC.Weapons.BARREL_FIRE_MODE.SINGLE" (event "gunEntity.barrelsModifier.evModeChanged"))
        (var isBetweenShots:bool = "gunEntity.barrelsModifier.isBetweenShots" (event "gunEntity.barrelsModifier.evBetweenShotsChanged"))

        (var gunBarrelEntity:gfx = "$datahub.getEntity(_mostReadyId)")
        (var isBarrelCharging:bool = "gunBarrelEntity.gunBarrel.isCharging" (event "gunBarrelEntity.gunBarrel.evChanged"))

        (var isBarrelProgress:bool = "barrelShotMode && !isCrit && (isBarrelCharging || isBetweenShots)")

        (var progressComponent:gfx = "isBarrelProgress ? gunBarrelEntity.progress : gunEntity.progress" (event "gunEntity.evAdded") (event "gunEntity.evRemoved"))

        (var progressMax:number = "progressComponent ? progressComponent.max : 1" (event "progressComponent.evChanged"))
        (var progressTime:number = "progressComponent ? progressComponent.value : 0" (event "progressComponent.evChanged"))

        (var remainTime:number = "(progressComponent && !isWorking)
                                        ? isNotSwitchingCriticalAndIsCrit
                                            ? progressTime
                                            : (progressMax - progressTime)
                                        : 0" (event "progressComponent.evChanged"))

        (var hasRemainTime:bool = "remainTime > 0")

        (macro MOD_RT_COUNTDOWN_SCOPE "remainTime")

        (var avatar:gfx = "$datahub.getSingleEntity(CC.playerAvatar)")

        (macro MOD_RT_GET_RELOAD_VALUE_SCOPE "avatar.id" "gunType") # return reloadTime

        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)
    )

    (class $ModRTReloadBarTimeLeft)

    (block
        (bind visible "isNotSwitchingCriticalAndIsCrit")

        (class $ModRTIconRepair)
    )

    (tf
        (class $TextDefaultNM)
        (class $FontEnableReadability)
        (style
            (alpha=0.9)
            (bind textColor "(isReady && battleStarted) ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
        )

        (bind text "hasRemainTime ? countdownText : (reloadTime > 0 ? reloadTimeText : '')")
    )
)

# orig \gui\unbound2\pc\battle\reload_bar\guns_reload_bar.unbound
(def element SerialReloadBarTimeLeft (_reloadBarState:number, _progressEntityId:number) layout=true
    (scope
        (var progressComponent:gfx = "$datahub.getEntity(_progressEntityId).progress")
        (var progressMax:number = "progressComponent ? progressComponent.max : 1" (event "progressComponent.evChanged"))
        (var progressTime:number = "progressComponent ? progressComponent.value : 0" (event "progressComponent.evChanged"))

        (var isReady:bool = "_reloadBarState == ReloadBarState.NORMAL")
        (var isCrit:bool = "_reloadBarState == ReloadBarState.CRIT")

        (var remainTime:number = "progressComponent    ? isCrit    ? progressTime
                                                                : progressMax - progressTime
                                                    : 0")
        (var hasRemainTime:bool = "remainTime > 0")

        (macro MOD_RT_COUNTDOWN_SCOPE "remainTime")

        (macro MOD_RT_BATTLE_STATE_COMPONENT_SCOPE)
    )

    (class $ModRTReloadBarTimeLeft)

    (block
        (bind visible "isCrit")

        (class $ModRTIconRepair)
    )

    (tf
        (class $TextDefaultNM)
        (class $FontEnableReadability)
        (style
            (alpha=0.9)
            (bind textColor "(isReady && battleStarted) ? MOD_RT_RELOAD_TIME_TEXT_COLOR : 0xFFFFFFFF")
        )

        (bind text "hasRemainTime ? countdownText : (progressMax > 0 ? formatFloatingPoint(progressMax, 1, false) : '')")
    )
)
 

 

(def constant MOD_RT_SLOT_RELOAD_FONT_SIZE 38)

  • Плюс 2
  • Круто 1

Рассказать о публикации


Ссылка на публикацию

×