ModDota / BugTracker

Listing bugs for Dota 2 Custom Games
9 stars 1 forks source link

Default pick UI overlays the team setup UI #67

Closed rossengeorgiev closed 7 years ago

rossengeorgiev commented 7 years ago

What happens

Default pick UI shows over team setup UI during DOTA_GAMERULES_STATE_CUSTOM_GAME_SETUP. Players can't pick heroes as the button is greyed and there is no timer at the top. However, host can click where the lock + start button is to proceed.

I've overlayed the two screens to illustrate.

170129h4nrk

Expected

Setup screen to choose team, shuffle players and then pick screen

Workarounds

  1. Have SetCustomGameForceHero and custom pick screen
  2. Or GameRules:SetCustomGameSetupAutoLaunchDelay(0)

It's important to note that if the custom game is using GameRules:EnableCustomGameSetupAutoLaunch(false) players will be stuck on the unusable pick screen. Unless the hosts clicks about where the Lock + Start button is.

Yahnich commented 7 years ago

you could probably just check the state and set the heroselection panel style to collapse

devilesk commented 7 years ago

@Yahnich good idea, I just tried it and it works. I think this is the best workaround. Here's how I implemented it.

Panorama script:

function ShowHeroSelection() {
    $.GetContextPanel().GetParent().GetParent().GetParent().GetParent().FindChild("PreGame").visible = true;
}

$.GetContextPanel().GetParent().GetParent().GetParent().GetParent().FindChild("PreGame").visible = false;
GameEvents.Subscribe( "show_hero_selection", ShowHeroSelection );

Lua script:


function CHeroDemo:OnGameRulesStateChange()
    local nNewState = GameRules:State_Get()
    if nNewState == DOTA_GAMERULES_STATE_HERO_SELECTION then
        CustomGameEventManager:Send_ServerToAllClients("show_hero_selection", {} )
    end
end

ListenToGameEvent( "game_rules_state_change", Dynamic_Wrap( CHeroDemo, 'OnGameRulesStateChange' ), self )
SinZ163 commented 7 years ago

@devilesk why not just listen to game_rules_state_change client side, avoid lua all together

mrze commented 7 years ago

@devilesk I think your workaround has a bug, when I load into your sandbox custom game, about 10 seconds after hero spawns the hero select overlay appears over the top of gameplay. Here is a screenshot about 10 seconds after hero spawns into the game: http://imgur.com/a/KpSU0

devilesk commented 7 years ago

@mrze Thanks for letting me know. I think I got it working now. The problem was that I was setting the visibility of that element directly while it looks like the client is changing the visibility of the PreGame HUD element by applying a class called Hidden. But setting the element to visible was overriding the effects of that class. So I just added another function for hiding it again once the state changes to pre game.

I also moved the script to just be inlined in the custom_ui_manifest.xml which changes how I get the PreGame element (less GetParent calls).

    <script>
function ShowHeroSelection() {
    $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = true;
}
function HideHeroSelection() {
    $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = false;
}
(function()
{
    $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = false;
    GameEvents.Subscribe( "show_hero_selection", ShowHeroSelection );
    GameEvents.Subscribe( "hide_hero_selection", HideHeroSelection );
})();
    </script>
function CHeroDemo:OnGameRulesStateChange()
    local nNewState = GameRules:State_Get()
    if nNewState == DOTA_GAMERULES_STATE_HERO_SELECTION then
        CustomGameEventManager:Send_ServerToAllClients("show_hero_selection", {} )
    elseif nNewState == DOTA_GAMERULES_STATE_PRE_GAME then
        CustomGameEventManager:Send_ServerToAllClients("hide_hero_selection", {} )
    end
end

@SinZ163 I didn't know that event was available client side. I already had a lua function listening for that event so I just used that.

Here's a 100% client side solution:

function UpdateHeroSelection() {
    if (Game.GameStateIsBefore(DOTA_GameState.DOTA_GAMERULES_STATE_HERO_SELECTION)) {
        $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = false;
    }
    else if (Game.GameStateIs(DOTA_GameState.DOTA_GAMERULES_STATE_HERO_SELECTION)) {
        $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = true;
    }
    else if (Game.GameStateIs(DOTA_GameState.DOTA_GAMERULES_STATE_PRE_GAME)) {
        $.GetContextPanel().GetParent().GetParent().FindChild("PreGame").visible = false;
    }
}
(function()
{
    GameEvents.Subscribe( "game_rules_state_change", UpdateHeroSelection );
})();
rossengeorgiev commented 7 years ago

@devilesk would just throwing your 100% client code inline into custom_ui_manifest.xml work, or is something else needed?

Yahnich commented 7 years ago

should work, this is similar to sinz' hero selection fix

devilesk commented 7 years ago

@rossengeorgiev yeah you can just inline it in custom_ui_manifest.xml

DoctorGester commented 7 years ago

Fixed, throw out your h4x