Skip to content

Commit

Permalink
Display the maps where the selected player has the most SP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aessi committed Nov 5, 2019
1 parent 539bfce commit b20eb8f
Show file tree
Hide file tree
Showing 5 changed files with 359 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Variables shared between the menu and the game mode

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //
/** Set/Get the filename and url of the url to load
* automatically after loading a map in the solo campaign
*/
Void SetAutoLoadReplay(CSystemPlatform _System, Text _Login, Text _FileName, Text _Url) {
declare Text LibSharedVariables_AutoLoadReplayLogin for _System = "";
declare Text LibSharedVariables_AutoLoadReplayFileName for _System = "";
declare Text LibSharedVariables_AutoLoadReplayUrl for _System = "";
LibSharedVariables_AutoLoadReplayLogin = _Login;
LibSharedVariables_AutoLoadReplayFileName = _FileName;
LibSharedVariables_AutoLoadReplayUrl = _Url;
}
Text GetAutoLoadReplayLogin(CSystemPlatform _System) {
declare Text LibSharedVariables_AutoLoadReplayLogin for _System = "";
return LibSharedVariables_AutoLoadReplayLogin;
}
Text GetAutoLoadReplayFileName(CSystemPlatform _System) {
declare Text LibSharedVariables_AutoLoadReplayFileName for _System = "";
return LibSharedVariables_AutoLoadReplayFileName;
}
Text GetAutoLoadReplayUrl(CSystemPlatform _System) {
declare Text LibSharedVariables_AutoLoadReplayUrl for _System = "";
return LibSharedVariables_AutoLoadReplayUrl;
}
Void ResetAutoLoadReplay(CSystemPlatform _System) {
SetAutoLoadReplay(_System, "", "", "");
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ Text Build() {
declare Real MarginX_ButtonTrack = 4.0;
declare Real PosXFirstTrack = 58.8;
declare Real PosYFirstTrack = 36.6;

declare Integer Count_InstancesOpponentRecordY = 10;
declare Integer Count_InstancesOpponentRecordX = 1;
declare Real MarginY_ButtonOpponentRecord = 0.3;
declare Real MarginX_ButtonOpponentRecord = 4.0;
declare Real PosXFirstOpponentRecord = 130.;
declare Real PosYFirstOpponentRecord = 36.6;

declare Text IMGArrow = "file://Media/MEDIABROWSER_HiddenResources/Common/Images/Menus/Buttons/FlecheTri.dds";
declare Text IMGButton = "file://Media/MEDIABROWSER_HiddenResources/Common/Images/Menus/Buttons/Button_Scroll_v.dds";
Expand Down Expand Up @@ -53,6 +60,17 @@ Text Build() {
</frame>
</frame>
</framemodel>
<framemodel id="MenuButtons_FrameModelOpponentRecord">
<frame id="Frame_Button">
<quad id="MenuButtons_OpponentRecord" halign="right" valign="center" size="{{{SizeXQuad}}} {{{SizeYQuad}}}" pos="0 0" z-index="-4" opacity="0.5" bgcolor="000" bgcolorfocus="fff" scriptevents="1" />
<quad id="MenuButtons_Color" halign="right" valign="bottom" size="15.3 0.5" z-index="-3" pos="0 {{{-SizeYQuad/2.}}}" opacity="0." bgcolor="090" scriptevents="1" />
<quad id="MenuButtons_Barre" halign="center" valign="center" size="0.2 {{{SizeYQuad-2.5}}}" pos="{{{-SizeXQuad+10.4}}} 0" opacity="0.2" z-index="-2" bgcolor="fff" hidden="1"/>
<label id="MenuButtons_Score" halign="right" valign="center" size="14 {{{SizeYQuad}}}" textfont="{{{ChronoFont}}}" pos="-9 0.5" opacity="1.0" z-index="2" textsize="3" textcolor="{{{Green2}}}"/>
<quad halign="left" valign="center" size="5 5" pos="-8 0" style="Icons128x128_1" substyle="SkillPoints" keepratio="fit"/>
<label id="MenuButtons_Rank" halign="right" valign="center" size="8 {{{SizeYQuad}}}" textfont="{{{ChronoFont}}}" pos="{{{-SizeXQuad+9.}}} {{{0.5}}}" opacity="1.0" z-index="2" textsize="5" text=""/>
<label id="MenuButtons_Label" halign="left" valign="center" size="{{{SizeXQuad - 38.}}} {{{SizeYQuad}}}" pos="{{{-SizeXQuad+14.}}} {{{0.5}}}" opacity="1.0" z-index="2" textsize="3" text=""/>
</frame>
</framemodel>
<framemodel id="MenuButtons_FrameModelTrack">
<frame id="Frame_Button">
<quad id="MenuButtons_Track" halign="right" valign="center" size="{{{SizeXQuadTrack}}} {{{SizeYQuad}}}" pos="0 0" z-index="1" opacity="0.5" bgcolor="000" scriptevents="1" />
Expand Down Expand Up @@ -127,8 +145,25 @@ Text Build() {
}
}
MLText^="""
</frame>

</frame>

<label id="Label_OpponentName" pos="{{{PosXFirstOpponentRecord-SizeXQuad/2.}}} {{{PosYFirstOpponentRecord+SizeYQuad}}}" halign="center" valign="center" textfont="{{{MainFont}}}" opacity="1.0" z-index="2" textsize="5" text=""/>
<frame id="frame_OpponentRecords" hidden="1">""";
for(I, 0, Count_InstancesOpponentRecordY-1)
{
declare Real IndexY = I*1.;
declare Real PosnY = PosYFirstOpponentRecord + IndexY*-SizeYQuad - IndexY*MarginY_ButtonOpponentRecord*1.;
for(J, 0, Count_InstancesOpponentRecordX-1)
{
declare Real IndexX = J*1.;
declare Real PosnX = PosXFirstOpponentRecord + IndexX*SizeXQuad + IndexX*MarginX_ButtonOpponentRecord*1.;
MLText^="""
<frameinstance modelid="MenuButtons_FrameModelOpponentRecord" z-index="5." pos="{{{PosnX}}} {{{PosnY}}}" id="Frame_ButtonOpponentRecord{{{I}}}"/>
""";
}
}
MLText^="""
</frame>

<frame id="Frame_Header" z-index="1" pos="90.0 35" hidden="1">
<quad id="Quad_Section" scriptevents="1" halign="right" valign="center" pos="26.5 -0.5" size="54.5 15" opacity="0.4" bgcolor="000"/>
Expand Down Expand Up @@ -164,6 +199,16 @@ Text Build() {
<script><!--
#Const C_TimeNextZone 4500

#Struct K_MapRecord {
Text MapName;
Integer SkillPoints;
Text Thumbnail;
Text MapPath;
Text ReplayLogin;
Text ReplayFileName;
Text ReplayUrl;
}

{{{Manialink::GetIncludes()}}}

declare Text[] G_ZoneNames;
Expand Down Expand Up @@ -223,7 +268,7 @@ Text Build() {
declare CMlFrame Habillage_Menu_Down <=> (Page.MainFrame.GetFirstChild("Habillage_Menu_Down") as CMlFrame);
declare CMlQuad Line0 <=> (Habillage_Menu_Down.GetFirstChild("Line0") as CMlQuad);
declare CMlQuad Line1 <=> (Habillage_Menu_Down.GetFirstChild("Line1") as CMlQuad);
declare Vec2 Menu_DownPos = <60.0, Habillage_Menu_Down.RelativePosition.Y>;
declare Vec2 Menu_DownPos = <60.0, Habillage_Menu_Down.RelativePosition_V3.Y>;
LibManialink_SetTargetPosition(Habillage_Menu_Down, Menu_DownPos);
LibManialink_PresetAnim(Habillage_Menu_Down, AnimationTime, "EaseOutQuint");
declare Vec2 Line0Size = <136., Line0.Size.Y>;
Expand Down Expand Up @@ -251,7 +296,7 @@ Text Build() {
declare CMlFrame Habillage_Menu_Down <=> (Page.MainFrame.GetFirstChild("Habillage_Menu_Down") as CMlFrame);
declare CMlQuad Line0 <=> (Habillage_Menu_Down.GetFirstChild("Line0") as CMlQuad);
declare CMlQuad Line1 <=> (Habillage_Menu_Down.GetFirstChild("Line1") as CMlQuad);
declare Vec2 Menu_DownPos = <10.0, Habillage_Menu_Down.RelativePosition.Y>;
declare Vec2 Menu_DownPos = <10.0, Habillage_Menu_Down.RelativePosition_V3.Y>;
LibManialink_SetTargetPosition(Habillage_Menu_Down, Menu_DownPos);
LibManialink_PresetAnim(Habillage_Menu_Down, AnimationTime, "EaseOutQuint");
declare Vec2 Line0Size = <86., Line0.Size.Y>;
Expand Down Expand Up @@ -297,6 +342,13 @@ Text Build() {
declare Integer QuadId for MenuButtons_Player;
QuadId = I;
}
for(I, 0, {{{Count_InstancesOpponentRecordY-1}}})
{
declare CMlFrame ButtonsFrame <=> (Page.GetFirstChild("Frame_ButtonOpponentRecord"^I) as CMlFrame);
declare CMlQuad MenuButtons_OpponentRecord <=> (ButtonsFrame.GetFirstChild("MenuButtons_OpponentRecord") as CMlQuad);
declare Integer QuadId for MenuButtons_OpponentRecord;
QuadId = I;
}
for(I, 0, {{{Count_InstancesTrackY-1}}})
{
declare CMlFrame ButtonsFrame <=> (Page.GetFirstChild("Frame_ButtonTrack"^I) as CMlFrame);
Expand Down Expand Up @@ -406,7 +458,7 @@ Text Build() {
if(I < G_Max_Tracks)
{

Frame_Button.RelativePosition.X = 7.;
Frame_Button.RelativePosition_V3.X = 7.;
LibManialink_AnimStop(MenuButtons_Track);
LibManialink_AnimStop(MenuButtons_Color);
LibManialink_AnimStop(MenuButtons_Score);
Expand Down Expand Up @@ -461,6 +513,7 @@ Text Build() {
declare Integer[] Page_PlayersRankList for Page;
declare Integer[] Page_PlayersScoreList for Page;
declare Text Page_PlayersZone for Page;
declare Text[] Page_PlayersLoginList for Page;
G_MenuButton_Player_FocusY = 0;
declare CMlLabel Label_PlayerZone <=> (Page.MainFrame.GetFirstChild("Label_PlayerZone") as CMlLabel);

Expand Down Expand Up @@ -489,10 +542,7 @@ Text Build() {
LastRank = Rank;
MenuButtons_Score.SetText(""^Page_PlayersScoreList[I]);
if (I == {{{Count_InstancesPlayerY - 1}}}) {
if (Rank > {{{Count_InstancesPlayerY}}} && LocalUser.Name == Page_PlayersNameList[I]) {
// TODO : Hack deg deja décrit :
// remplacer LocalUser.Name == Page_PlayersNameList[I]
// par LocalUser.Login == Page_PlayersLoginList[I]
if (Rank > {{{Count_InstancesPlayerY}}} && LocalUser.Login == Page_PlayersLoginList[I]) {
PlayerSeparator_Frame.Show();
ButtonsFrame.RelativePosition_V3.Y = - 72.2;
Habillage_Menu_Down.RelativePosition_V3.Y = - 80.5;
Expand All @@ -516,6 +566,43 @@ Text Build() {
}
G_Max_Players = Page_PlayersNameList.count;
}

Void Update_OpponentRecords() {
declare CMlFrame Frame_OpponentRecords <=> (Page.GetFirstChild("frame_OpponentRecords") as CMlFrame);
Frame_OpponentRecords.Visible = True;

declare K_MapRecord[] Ranking_OpponentRecords for Page;
for(I, 0, {{{Count_InstancesOpponentRecordY-1}}})
{
declare CMlFrame ButtonsFrame <=> (Frame_OpponentRecords.GetFirstChild("Frame_ButtonOpponentRecord"^I) as CMlFrame);
declare CMlLabel MenuButtons_Label <=> (ButtonsFrame.GetFirstChild("MenuButtons_Label") as CMlLabel);
declare CMlLabel MenuButtons_Score <=> (ButtonsFrame.GetFirstChild("MenuButtons_Score") as CMlLabel);
declare CMlLabel MenuButtons_Rank <=> (ButtonsFrame.GetFirstChild("MenuButtons_Rank") as CMlLabel);
declare CMlQuad MenuButtons_Barre <=> (ButtonsFrame.GetFirstChild("MenuButtons_Barre") as CMlQuad);

if(Ranking_OpponentRecords.existskey(I)) {
declare K_MapRecord Record = Ranking_OpponentRecords[I];
MenuButtons_Barre.Show();
MenuButtons_Label.SetText(Record.MapName);
MenuButtons_Score.SetText(""^Record.SkillPoints);
MenuButtons_Rank.Opacity = 1.0;
} else {
MenuButtons_Barre.Hide();
MenuButtons_Label.SetText("");
MenuButtons_Score.SetText("");
MenuButtons_Rank.Opacity = 0.5;
}
SetRankText(MenuButtons_Rank, I + 1, False);
}
}

Void Select_OpponentRecord(Integer _QuadId) {
declare K_MapRecord[] Ranking_OpponentRecords for Page;
if(Ranking_OpponentRecords.existskey(_QuadId)) {
declare K_MapRecord Record = Ranking_OpponentRecords[_QuadId];
SendCustomEvent("Solo_PlayMap", [Record.MapPath, Record.Thumbnail, Record.ReplayLogin, Record.ReplayFileName, Record.ReplayUrl]);
}
}

Void Update_TracksLabels()
{
Expand Down Expand Up @@ -578,9 +665,21 @@ Text Build() {
declare CMlQuad MenuButtons_Track <=> (ButtonsFrame.GetFirstChild("MenuButtons_Track") as CMlQuad);
G_MenuButton_ControlFocus = MenuButtons_Track;
}

Void GetOpponentRecord(Integer _QuadId) {
SendCustomEvent("GetOpponentRecords", [_QuadId^""]);

declare Text[] Page_PlayersNameList for Page;
if (Page_PlayersNameList.existskey(_QuadId)) {
declare CMlLabel Label_OpponentName <=> (Page.MainFrame.GetFirstChild("Label_OpponentName") as CMlLabel);
Label_OpponentName.Value = Page_PlayersNameList[_QuadId];
}
}

Void PressSelect(Integer _QuadId)
{
GetOpponentRecord(_QuadId);

// On supprime les profiles côté live. Je laisse le code commenté au cas où on aurait de nouveaux des profiles.
// SendCustomEvent("ShowProfile", [_QuadId^""]);
return;
Expand Down Expand Up @@ -641,21 +740,21 @@ Text Build() {
declare Vec2 NewFramePosition = {{{Label_Score_ShownPos}}};
declare CMlFrame Frame_ButtonPlayer <=> (Page.GetFirstChild("Frame_ButtonPlayer"^I) as CMlFrame);
declare CMlFrame Frame_Button <=> (Frame_ButtonPlayer.GetFirstChild("Frame_Button") as CMlFrame);
Frame_Button.RelativePosition.X = 40.+I*6.;
Frame_Button.RelativePosition_V3.X = 40.+I*6.;
LibManialink_AnimStop(Frame_Button);
LibManialink_SetTargetPosition(Frame_Button, <0., 0.>);
LibManialink_PresetAnimInsert(Frame_Button, Decal, Speed/2, "EaseOutCubic");
if (I == {{{Count_InstancesPlayerY - 1}}}) {
declare CMlFrame PlayerSeparator_Frame <=> (Page.GetFirstChild("PlayerSeparator_Frame") as CMlFrame);
PlayerSeparator_Frame.RelativePosition.X = 40.+I*6.;
PlayerSeparator_Frame.RelativePosition_V3.X = 40.+I*6.;
LibManialink_AnimStop(PlayerSeparator_Frame);
LibManialink_SetTargetPosition(PlayerSeparator_Frame, <0., 0.>);
LibManialink_PresetAnimInsert(PlayerSeparator_Frame, Decal, Speed/2, "EaseOutCubic");
}
Decal += 40;
}

Frame_All.RelativePosition.X = 250.;
Frame_All.RelativePosition_V3.X = 250.;
LibManialink_AnimStop(Frame_All);
LibManialink_SetTargetPosition(Frame_All, <0., 0.>);
LibManialink_PresetAnimInsert(Frame_All, 100, Speed, "EaseOutCubic");
Expand Down Expand Up @@ -698,6 +797,7 @@ Text Build() {
main() {

Init();


while(True) {

Expand All @@ -711,24 +811,24 @@ Text Build() {
foreach(Event in PendingEvents) {
switch(Event.Type) {

case CMlEvent::Type::MenuNavigation: {
case CMlScriptEvent::Type::MenuNavigation: {
switch(Event.MenuNavAction) {
case CMlEvent::EMenuNavAction::Action1 : {
case CMlScriptEvent::EMenuNavAction::Action1 : {
//if(G_InfoRankingIsShow) HideInfoRanking();
//else ShowInfoRanking();
//G_InfoRankingIsShow = !G_InfoRankingIsShow;
}
case CMlEvent::EMenuNavAction::Cancel : {
case CMlScriptEvent::EMenuNavAction::Cancel : {
if(G_MenuButton_Player_SelectY != -1)
{
CancelPlayerSelect(G_MenuButton_Player_SelectY);
}
else
{
SendCustomEvent("GotoPrevious", Text[]);
SendCustomEvent("GotoPrevious", []);
}
}
case CMlEvent::EMenuNavAction::Down : {
case CMlScriptEvent::EMenuNavAction::Down : {
if(G_MenuButton_Player_SelectY == -1 || G_MenuButton_Player_FocusY != -1)
{
if(G_MenuButton_Player_FocusY < G_Max_Players-1)
Expand Down Expand Up @@ -762,25 +862,25 @@ Text Build() {
}
}
}
case CMlEvent::EMenuNavAction::Right : {
case CMlScriptEvent::EMenuNavAction::Right : {
if(G_MenuButton_Player_SelectY == -1)
{
ZonePrevious();
}
}
case CMlEvent::EMenuNavAction::Left : {
case CMlScriptEvent::EMenuNavAction::Left : {
if(G_MenuButton_Player_SelectY == -1)
{
ZoneNext();
}
}
case CMlEvent::EMenuNavAction::PageUp : {
case CMlScriptEvent::EMenuNavAction::PageUp : {
SendCustomEvent("Barre_PageUp", [""]);
}
case CMlEvent::EMenuNavAction::PageDown : {
case CMlScriptEvent::EMenuNavAction::PageDown : {
SendCustomEvent("Barre_PageDown", [""]);
}
case CMlEvent::EMenuNavAction::Up : {
case CMlScriptEvent::EMenuNavAction::Up : {
if(G_MenuButton_Player_SelectY == -1 || G_MenuButton_Player_FocusY != -1)
{
if(G_MenuButton_Player_FocusY > 0)
Expand Down Expand Up @@ -814,15 +914,15 @@ Text Build() {
}
}
}
case CMlEvent::EMenuNavAction::Select : {
case CMlScriptEvent::EMenuNavAction::Select : {
PressSelect(G_MenuButton_Player_FocusY);
}
}
}
case CMlEvent::Type::MouseClick: {
case CMlScriptEvent::Type::MouseClick: {
if (Event.ControlId == "ButtonRecordCenterStart")
{
SendCustomEvent("RecordCenterStart", Text[]);
SendCustomEvent("RecordCenterStart", []);
declare CMlQuad Quad_Over <=> (Page.MainFrame.GetFirstChild(Event.ControlId^"Over") as CMlQuad);
Quad_Over.Hide();
}
Expand Down Expand Up @@ -852,8 +952,13 @@ Text Build() {
if(G_MenuButton_Player_SelectY != -1) CancelPlayerSelect(0);
ZoneNext();
}
else if (Event.ControlId == "MenuButtons_OpponentRecord")
{
declare Integer QuadId for Event.Control;
Select_OpponentRecord(QuadId);
}
}
case CMlEvent::Type::MouseOver: {
case CMlScriptEvent::Type::MouseOver: {
if (Event.ControlId == "Quad_Section")
{
//Event.Control.RelativeScale = 1.1;
Expand Down Expand Up @@ -885,7 +990,7 @@ Text Build() {
Quad_Over.Show();
}
}
case CMlEvent::Type::MouseOut: {
case CMlScriptEvent::Type::MouseOut: {
if (Event.ControlId == "Quad_Section")
{
Event.Control.RelativeScale = 1.;
Expand Down Expand Up @@ -914,14 +1019,17 @@ Text Build() {
Quad_Over.Hide();
}
}
case CMlEvent::Type::PluginCustomEvent: {
case CMlScriptEvent::Type::PluginCustomEvent: {
switch(Event.CustomEventType) {
case "Back" : {
SendCustomEvent("GotoPrevious", [""]);
}
case "Update_PlayersLabels" : {
Update_PlayersLabels();
}
case "Update_OpponentRecords": {
Update_OpponentRecords();
}
case "Update_TracksLabels" : {
Update_TracksLabels();
}
Expand Down
Loading

0 comments on commit b20eb8f

Please sign in to comment.