@@ -83,6 +83,8 @@ var hilariousLoadingPhrases = [
83
83
84
84
SetupTopBar ( ) ;
85
85
86
+ $ ( '#MainContent' ) . SetHasClass ( currentMap , true ) ;
87
+
86
88
CustomNetTables . SubscribeNetTableListener ( 'hero_selection' , onPlayerStatChange ) ;
87
89
CustomNetTables . SubscribeNetTableListener ( 'bottlepass' , UpdateBottleList ) ;
88
90
@@ -597,6 +599,8 @@ function ReloadCMStatus (data) {
597
599
// the "select your hero at the end" thing
598
600
if ( obj . side === teamID && obj . type === 'Pick' && obj . hero !== 'empty' ) {
599
601
ReturnChatWindow ( ) ;
602
+ $ ( '#MainContent' ) . SetHasClass ( 'CMHeroChoices' , true ) ;
603
+
600
604
var newbutton = $ . CreatePanel ( 'RadioButton' , FindDotaHudElement ( 'CMHeroPreview' ) , '' ) ;
601
605
newbutton . group = 'CMHeroChoises' ;
602
606
newbutton . AddClass ( 'CMHeroPreviewItem' ) ;
@@ -704,6 +708,7 @@ function PreviewHero (name) {
704
708
}
705
709
706
710
function UpdateBottlePassArcana ( heroName ) {
711
+ var playerID = Game . GetLocalPlayerID ( ) ;
707
712
$ ( '#ArcanaSelection' ) . RemoveAndDeleteChildren ( ) ;
708
713
709
714
if ( heroName !== 'npc_dota_hero_sohei' && heroName !== 'npc_dota_hero_electrician' ) {
@@ -712,11 +717,17 @@ function UpdateBottlePassArcana (heroName) {
712
717
}
713
718
$ ( '#ArcanaPanel' ) . SetHasClass ( 'HasArcana' , true ) ;
714
719
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
+
715
727
$ . Schedule ( 0.2 , function ( ) {
716
728
$ . Msg ( 'UpdateBottlePassArcana(' + heroName + ')' ) ;
717
729
var arcanas = null ;
718
730
719
- var playerID = Game . GetLocalPlayerID ( ) ;
720
731
var specialArcanas = CustomNetTables . GetTableValue ( 'bottlepass' , 'special_arcanas' ) ;
721
732
for ( var arcanaIndex in specialArcanas ) {
722
733
if ( specialArcanas [ arcanaIndex ] . PlayerId === playerID ) {
@@ -727,9 +738,9 @@ function UpdateBottlePassArcana (heroName) {
727
738
if ( heroName === 'npc_dota_hero_sohei' ) {
728
739
radio = $ . CreatePanel ( 'RadioButton' , $ ( '#ArcanaSelection' ) , 'DefaultSoheiSet' ) ;
729
740
radio . BLoadLayoutSnippet ( 'ArcanaRadio' ) ;
730
- radio . checked = true ;
731
741
radio . hero = heroName ;
732
742
radio . setName = 'DefaultSet' ;
743
+ radio . checked = selectedArcana === radio . setName ;
733
744
734
745
// Disabled
735
746
// radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'PepsiSoheiSet');
@@ -743,21 +754,23 @@ function UpdateBottlePassArcana (heroName) {
743
754
radio . BLoadLayoutSnippet ( 'ArcanaRadio' ) ;
744
755
radio . hero = heroName ;
745
756
radio . setName = 'DBZSohei' ;
757
+ radio . checked = selectedArcana === radio . setName ;
746
758
}
747
759
}
748
760
} else if ( heroName === 'npc_dota_hero_electrician' ) {
749
761
radio = $ . CreatePanel ( 'RadioButton' , $ ( '#ArcanaSelection' ) , 'DefaultElectricianSet' ) ;
750
762
radio . BLoadLayoutSnippet ( 'ArcanaRadio' ) ;
751
- radio . checked = true ;
752
763
radio . hero = heroName ;
753
764
radio . setName = 'DefaultSet' ;
765
+ radio . checked = selectedArcana === radio . setName ;
754
766
755
767
// Disabled
756
768
757
769
// radio = $.CreatePanel('RadioButton', $('#ArcanaSelection'), 'RockElectricianSet');
758
770
// radio.BLoadLayoutSnippet('ArcanaRadio');
759
771
// radio.hero = heroName;
760
772
// radio.setName = 'RockElectrician';
773
+ // radio.checked = selectedArcana === radio.setName;
761
774
}
762
775
SelectArcana ( ) ;
763
776
} ) ;
@@ -768,6 +781,19 @@ function SelectArcana () {
768
781
if ( arcanasList . GetChildCount ( ) > 0 ) {
769
782
var selectedArcana = $ ( '#ArcanaSelection' ) . Children ( ) [ 0 ] . GetSelectedButton ( ) ;
770
783
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
+
771
797
var data = {
772
798
Hero : selectedArcana . hero ,
773
799
Arcana : selectedArcana . setName ,
@@ -780,37 +806,43 @@ function SelectArcana () {
780
806
}
781
807
782
808
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
+
783
818
$ ( '#BottleSelection' ) . RemoveAndDeleteChildren ( ) ;
784
- SelectBottle ( ) ;
785
819
// Wait the parent be updated
786
820
$ . 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 ( ) ] ;
794
826
}
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 ) ;
800
829
var bottleCount = Object . keys ( bottles ) . length ;
801
830
Object . keys ( bottles ) . forEach ( function ( bottleId , i ) {
802
831
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 ) ;
810
833
} ) ;
834
+
835
+ SelectBottle ( ) ;
811
836
} ) ;
812
837
}
813
838
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
+
814
846
function SelectBottle ( ) {
815
847
var bottleId = 0 ;
816
848
var btn = $ ( '#Bottle0' ) ;
0 commit comments