Example #1
0
 private void RefreshParticipantScoreLine(AgeTransform tableitem, EmpireInfo empireInfo, int index)
 {
     tableitem.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
     if (this.visibleEmpires.Contains(empireInfo.EmpireIndex))
     {
         tableitem.Visible = true;
         ParticipantScoreLine component = tableitem.GetComponent <ParticipantScoreLine>();
         component.ParticipantName.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
         component.ParticipantScore.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
         component.ParticipantLogoBackground.TintColor = empireInfo.FactionColor;
         component.ParticipantName.Text = empireInfo.LocalizedName;
         GuiFaction guiFaction = new GuiFaction(empireInfo.Faction);
         component.ParticipantLogo.Image = guiFaction.GetImageTexture(GuiPanel.IconSize.LogoLarge, true);
         Snapshot[] snapshots = this.Snapshot.Snapshots;
         string     name      = string.Format("Turn #{0}", snapshots.Length - 1);
         Snapshot   snapshot;
         Snapshot   snapshot2;
         if (this.Snapshot.TryGetSnapshot(name, out snapshot) && snapshot.TryGetSnapshot(empireInfo.EmpireName, out snapshot2))
         {
             float num;
             snapshot2.TryRead(this.CurrentScoreDefinition.Name, out num);
             string str      = "";
             int    decimals = 0;
             component.ParticipantScore.WordWrap = false;
             if (num >= 1000f)
             {
                 str = "k";
                 if (num <= 10000f)
                 {
                     num      = Mathf.Round(num / 100f);
                     num     /= 10f;
                     decimals = 1;
                 }
                 else if (num <= 999999f)
                 {
                     num = Mathf.Round(num / 1000f);
                 }
                 else if (num <= 9999999f)
                 {
                     num      = Mathf.Round(num / 100000f);
                     num     /= 10f;
                     str      = "M";
                     decimals = 1;
                 }
                 else if (num > 9999999f)
                 {
                     num = Mathf.Round(num / 1000000f);
                     str = "M";
                 }
             }
             component.ParticipantScore.Text = GuiFormater.FormatGui(num, false, false, false, decimals) + str;
             return;
         }
     }
     else
     {
         tableitem.Visible = false;
     }
 }