Skip to content

Commit f5f7e7b

Browse files
carlosrpgchrisinajar
authored andcommitted
Fix Bottlepass locking Captains Mode Selection (#2343)
* Fix Selection on Captains Mode, Add Sohei Arcana to picking screen * Semistandard changes
1 parent 5dd33c4 commit f5f7e7b

File tree

4 files changed

+71
-29
lines changed

4 files changed

+71
-29
lines changed
107 KB
Binary file not shown.

content/panorama/scripts/custom_game/hero_selection.js

+55-23
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ var hilariousLoadingPhrases = [
8383

8484
SetupTopBar();
8585

86+
$('#MainContent').SetHasClass(currentMap, true);
87+
8688
CustomNetTables.SubscribeNetTableListener('hero_selection', onPlayerStatChange);
8789
CustomNetTables.SubscribeNetTableListener('bottlepass', UpdateBottleList);
8890

@@ -597,6 +599,8 @@ function ReloadCMStatus (data) {
597599
// the "select your hero at the end" thing
598600
if (obj.side === teamID && obj.type === 'Pick' && obj.hero !== 'empty') {
599601
ReturnChatWindow();
602+
$('#MainContent').SetHasClass('CMHeroChoices', true);
603+
600604
var newbutton = $.CreatePanel('RadioButton', FindDotaHudElement('CMHeroPreview'), '');
601605
newbutton.group = 'CMHeroChoises';
602606
newbutton.AddClass('CMHeroPreviewItem');
@@ -704,6 +708,7 @@ function PreviewHero (name) {
704708
}
705709

706710
function UpdateBottlePassArcana (heroName) {
711+
var playerID = Game.GetLocalPlayerID();
707712
$('#ArcanaSelection').RemoveAndDeleteChildren();
708713

709714
if (heroName !== 'npc_dota_hero_sohei' && heroName !== 'npc_dota_hero_electrician') {
@@ -712,11 +717,17 @@ function UpdateBottlePassArcana (heroName) {
712717
}
713718
$('#ArcanaPanel').SetHasClass('HasArcana', true);
714719

720+
var selectedArcanas = CustomNetTables.GetTableValue('bottlepass', 'selected_arcanas');
721+
var selectedArcana = 'DefaultSet';
722+
723+
if (selectedArcanas !== undefined && selectedArcanas[playerID.toString()] !== undefined) {
724+
selectedArcana = selectedArcanas[playerID.toString()][heroName];
725+
}
726+
715727
$.Schedule(0.2, function () {
716728
$.Msg('UpdateBottlePassArcana(' + heroName + ')');
717729
var arcanas = null;
718730

719-
var playerID = Game.GetLocalPlayerID();
720731
var specialArcanas = CustomNetTables.GetTableValue('bottlepass', 'special_arcanas');
721732
for (var arcanaIndex in specialArcanas) {
722733
if (specialArcanas[arcanaIndex].PlayerId === playerID) {
@@ -727,9 +738,9 @@ function UpdateBottlePassArcana (heroName) {
727738
if (heroName === 'npc_dota_hero_sohei') {
728739
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultSoheiSet');
729740
radio.BLoadLayoutSnippet('ArcanaRadio');
730-
radio.checked = true;
731741
radio.hero = heroName;
732742
radio.setName = 'DefaultSet';
743+
radio.checked = selectedArcana === radio.setName;
733744

734745
// Disabled
735746
// radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'PepsiSoheiSet');
@@ -743,21 +754,23 @@ function UpdateBottlePassArcana (heroName) {
743754
radio.BLoadLayoutSnippet('ArcanaRadio');
744755
radio.hero = heroName;
745756
radio.setName = 'DBZSohei';
757+
radio.checked = selectedArcana === radio.setName;
746758
}
747759
}
748760
} else if (heroName === 'npc_dota_hero_electrician') {
749761
radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'DefaultElectricianSet');
750762
radio.BLoadLayoutSnippet('ArcanaRadio');
751-
radio.checked = true;
752763
radio.hero = heroName;
753764
radio.setName = 'DefaultSet';
765+
radio.checked = selectedArcana === radio.setName;
754766

755767
// Disabled
756768

757769
// radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'RockElectricianSet');
758770
// radio.BLoadLayoutSnippet('ArcanaRadio');
759771
// radio.hero = heroName;
760772
// radio.setName = 'RockElectrician';
773+
// radio.checked = selectedArcana === radio.setName;
761774
}
762775
SelectArcana();
763776
});
@@ -768,6 +781,19 @@ function SelectArcana () {
768781
if (arcanasList.GetChildCount() > 0) {
769782
var selectedArcana = $('#ArcanaSelection').Children()[0].GetSelectedButton();
770783

784+
var id = 'Scene' + ~~(Math.random() * 100);
785+
var preview = FindDotaHudElement('HeroPreview');
786+
preview.RemoveAndDeleteChildren();
787+
if (selectedArcana.setName !== 'DefaultSet') {
788+
preview.BCreateChildren('<DOTAScenePanel particleonly="false" id="' + id + '" style="opacity-mask: url(\'s2r://panorama/images/masks/softedge_box_png.vtex\');" map="prefabs\\heroes\\' + selectedArcana.setName + '" renderdeferred="false" camera="camera1" rotateonhover="true" yawmin="-10" yawmax="10" pitchmin="-10" pitchmax="10"/>');
789+
} else {
790+
if (selectedArcana.hero === 'npc_dota_hero_sohei') {
791+
preview.BCreateChildren('<DOTAScenePanel particleonly="false" id="' + id + '" style="opacity-mask: url(\'s2r://panorama/images/masks/softedge_box_png.vtex\');" map="prefabs\\heroes\\sohei" renderdeferred="false" camera="camera1" rotateonhover="true" yawmin="-10" yawmax="10" pitchmin="-10" pitchmax="10"/>');
792+
} else if (selectedArcana.hero === 'npc_dota_hero_electrician') {
793+
preview.BCreateChildren('<DOTAScenePanel particleonly="false" id="' + id + '" style="opacity-mask: url(\'s2r://panorama/images/masks/softedge_box_png.vtex\');" map="prefabs\\heroes\\electrician" renderdeferred="false" camera="camera1" rotateonhover="true" yawmin="-10" yawmax="10" pitchmin="-10" pitchmax="10"/>');
794+
}
795+
}
796+
771797
var data = {
772798
Hero: selectedArcana.hero,
773799
Arcana: selectedArcana.setName,
@@ -780,37 +806,43 @@ function SelectArcana () {
780806
}
781807

782808
function UpdateBottleList () {
809+
var playerID = Game.GetLocalPlayerID();
810+
var specialBottles = CustomNetTables.GetTableValue('bottlepass', 'special_bottles');
811+
var bottles = specialBottles[playerID.toString()].Bottles;
812+
813+
if ($('#BottleSelection').GetChildCount() === Object.keys(bottles).length + 1) {
814+
// ignore repaint if radio is already filled
815+
return;
816+
}
817+
783818
$('#BottleSelection').RemoveAndDeleteChildren();
784-
SelectBottle();
785819
// Wait the parent be updated
786820
$.Schedule(0.2, function () {
787-
var playerID = Game.GetLocalPlayerID();
788-
var specialBottles = CustomNetTables.GetTableValue('bottlepass', 'special_bottles');
789-
var bottles = null;
790-
for (var bottleIndex in specialBottles) {
791-
if (specialBottles[bottleIndex].PlayerId === playerID) {
792-
bottles = specialBottles[bottleIndex].Bottles;
793-
}
821+
var selectedBottle;
822+
823+
var selectedBottles = CustomNetTables.GetTableValue('bottlepass', 'selected_bottles');
824+
if (selectedBottles !== undefined && selectedBottles[playerID.toString()] !== undefined) {
825+
selectedBottle = selectedBottles[playerID.toString()];
794826
}
795-
// Default Bottle
796-
// var radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle0');
797-
// radio.BLoadLayoutSnippet('BottleRadio');
798-
// radio.checked = true;
799-
// radio.bottleId = 0;
827+
828+
CreateBottleRadioElement(0, selectedBottle === 0);
800829
var bottleCount = Object.keys(bottles).length;
801830
Object.keys(bottles).forEach(function (bottleId, i) {
802831
var id = bottles[bottleId];
803-
var radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle' + id);
804-
radio.BLoadLayoutSnippet('BottleRadio');
805-
radio.bottleId = id;
806-
807-
if (i === bottleCount - 1) {
808-
radio.checked = true;
809-
}
832+
CreateBottleRadioElement(bottles[bottleId], selectedBottle === undefined ? i === bottleCount - 1 : id === selectedBottle);
810833
});
834+
835+
SelectBottle();
811836
});
812837
}
813838

839+
function CreateBottleRadioElement (id, isChecked) {
840+
var radio = $.CreatePanel('RadioButton', $('#BottleSelection'), 'Bottle' + id);
841+
radio.BLoadLayoutSnippet('BottleRadio');
842+
radio.bottleId = id;
843+
radio.checked = isChecked;
844+
}
845+
814846
function SelectBottle () {
815847
var bottleId = 0;
816848
var btn = $('#Bottle0');

content/panorama/styles/custom_game/hero_selection.css

+14-6
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ RadioButton.Disabled:selected {
505505
}
506506

507507
#HeroSelector {
508-
width: 35%;
508+
width: 37%;
509509
height: fill-parent-flow(1.0);
510510
flow-children: right;
511511
horizontal-align: center;
@@ -549,7 +549,8 @@ RadioButton.Disabled:selected {
549549
}
550550

551551
DOTAScenePanel {
552-
width: 100%;
552+
horizontal-align: middle;
553+
width: 80%;
553554
height: 100%;
554555
}
555556

@@ -605,15 +606,18 @@ DOTAScenePanel {
605606
}
606607

607608
#AbilityPreview {
608-
width: fill-parent-flow(1.0);
609+
horizontal-align: center;
609610
vertical-align: bottom;
610611
flow-children: right;
612+
overflow: scroll squish;
611613
}
612614

613615
#AbilityPreview DOTAAbilityImage {
614-
width: fill-parent-flow(1.0);
615616
tooltip-position: top;
616-
margin: 0px 3px;
617+
max-width: 67px;
618+
margin: 0px 5px;
619+
border: 2px solid grey;
620+
border-radius: 8px;
617621
}
618622

619623
#HeroPickContainer {
@@ -898,7 +902,7 @@ DOTAScenePanel {
898902
margin-top: 10%;
899903
transition-delay: 7s;
900904
}
901-
.CaptainsMode .BottlePassSelection{
905+
.captains_mode .BottlePassSelection{
902906
margin-top: -45px;
903907
}
904908

@@ -910,6 +914,10 @@ DOTAScenePanel {
910914
visibility: collapse;
911915
}
912916

917+
.captains_mode #AbilityPreview{
918+
height: 80px;
919+
}
920+
913921
.BottlePassSelection
914922
{
915923
height: 600px;

game/scripts/vscripts/components/heroselection/heroselection.lua

+2
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,14 @@ end
206206
function HeroSelection:OnBottleSelected (selectedBottle)
207207
if HeroSelection.SelectedBottle == nil then HeroSelection.SelectedBottle = {} end
208208
HeroSelection.SelectedBottle[selectedBottle.PlayerId] = selectedBottle.BottleId
209+
CustomNetTables:SetTableValue( 'bottlepass', 'selected_bottles', HeroSelection.SelectedBottle )
209210
end
210211

211212
function HeroSelection:OnArcanaSelected (selectedArcana)
212213
if HeroSelection.SelectedArcana == nil then HeroSelection.SelectedArcana = {} end
213214
if HeroSelection.SelectedArcana[selectedArcana.PlayerId] == nil then HeroSelection.SelectedArcana[selectedArcana.PlayerId] = {} end
214215
HeroSelection.SelectedArcana[selectedArcana.PlayerId][selectedArcana.Hero] = selectedArcana.Arcana
216+
CustomNetTables:SetTableValue( 'bottlepass', 'selected_arcanas', HeroSelection.SelectedArcana )
215217
end
216218

217219
function HeroSelection:GetSelectedBottleForPlayer(playerId)

0 commit comments

Comments
 (0)