Closed rossengeorgiev closed 7 years ago
you could probably just check the state and set the heroselection panel style to collapse
@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 )
@devilesk why not just listen to game_rules_state_change
client side, avoid lua all together
@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
@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 );
})();
@devilesk would just throwing your 100% client code inline into custom_ui_manifest.xml
work, or is something else needed?
should work, this is similar to sinz' hero selection fix
@rossengeorgiev yeah you can just inline it in custom_ui_manifest.xml
Fixed, throw out your h4x
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 thelock + start
button is to proceed.I've overlayed the two screens to illustrate.
Expected
Setup screen to choose team, shuffle players and then pick screen
Workarounds
SetCustomGameForceHero
and custom pick screenOr
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 theLock + Start
button is.