Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 |
class KFPerkProgressList extends GUIVertList; // Settings var() float ItemBorder; // Percent of Width to leave blank inside Item Background var() float ItemSpacing; // Number of Pixels between Items var() float ProgressBarHeight; // Percent of Height to make Progress Bar's Height var() float TextTopOffset; // Percent of Height to off Progress String from top of Progress Bar(typically negative) // Display var texture ItemBackground; var texture ProgressBarBackground; var texture ProgressBarForeground; // Strings var localized string OneThousandSuffix; var localized string OneMillionSuffix; var localized string DecimalPoint; var localized string UnitDelimiter; // State var array<string> RequirementString; var array<string> RequirementProgressString; var array<float> RequirementProgress; event InitComponent(GUIController MyController, GUIComponent MyOwner) { OnDrawItem = DrawPerk; Super.InitComponent(MyController, MyOwner); } function InitList() { if ( bNotify ) { CheckLinkedObjects(Self); } } function PerkChanged(KFSteamStatsAndAchievements KFStatsAndAchievements, int NewPerkIndex) { local int i, Numerator, Denominator; local float Progress; if ( !KFStatsAndAchievements.bUsedCheats ) { // Update the ItemCount and select the first item ItemCount = KFStatsAndAchievements.GetPerkProgressDetailsCount(NewPerkIndex); SetIndex(0); RequirementString.Remove(0, RequirementString.Length); RequirementProgressString.Remove(0, RequirementProgressString.Length); RequirementProgress.Remove(0, RequirementProgress.Length); for ( i = 0; i < ItemCount; i++ ) { KFStatsAndAchievements.GetPerkProgressDetails(NewPerkIndex, i, Numerator, Denominator, Progress); RequirementString[RequirementString.Length] = Repl(class'KFGameType'.default.LoadedSkills[NewPerkIndex].default.Requirements[i], "%x", FormatNumber(Denominator)); RequirementProgressString[RequirementProgressString.Length] = FormatNumber(Numerator)$"/"$FormatNumber(Denominator); RequirementProgress[RequirementProgress.Length] = Progress; } } if ( MyScrollBar != none ) { MyScrollBar.AlignThumb(); } } function DrawPerk(Canvas Canvas, int CurIndex, float X, float Y, float Width, float Height, bool bSelected, bool bPending) { local float AspectRatio; local float BorderSize; local float TempX, TempY; local float TempWidth, TempHeight; local array<string> WrappedArray; // Calculate the Aspect Ratio(Helps Widescreen) AspectRatio = Canvas.ClipX / Canvas.ClipY; // Calc BorderSize so we dont do it 10 times per draw BorderSize = (3.0 - AspectRatio) * ItemBorder * Width; // Offset for the Background TempX = X; TempY = Y + ItemSpacing / 2.0; // Initialize the Canvas Canvas.Style = 1; Canvas.Font = class'ROHUD'.Static.GetSmallMenuFont(Canvas); Canvas.SetDrawColor(255, 255, 255, 255); // Draw Item Background Canvas.SetPos(TempX, TempY); Canvas.DrawTileStretched(ItemBackground, Width, Height - ItemSpacing); // Offset Border TempX += BorderSize; TempY += ((3.0 - AspectRatio) * BorderSize) + (TextTopOffset * Height); // Draw the Requirement string Canvas.SetDrawColor(192, 192, 192, 255); Canvas.WrapStringToArray(RequirementString[CurIndex], WrappedArray, Width - BorderSize * 2.0); Canvas.SetPos(TempX, TempY); Canvas.DrawText(WrappedArray[0]); // Draw Second Line of Requirement string(if necessary) if ( WrappedArray.Length > 1 ) { Canvas.StrLen(WrappedArray[0], TempWidth, TempHeight); Canvas.SetPos(TempX, TempY + (TempHeight * 0.8)); Canvas.DrawText(WrappedArray[1]); } // Get Width of Requirements Progress String Canvas.StrLen(RequirementProgressString[CurIndex], TempWidth, TempHeight); TempX = Width - TempWidth - BorderSize; TempY = Y + Height - TempHeight; // Draw the Requirement's Progress String Canvas.SetPos(X + TempX + 2.0, TempY - 2.0); Canvas.DrawText(RequirementProgressString[CurIndex]); // Create gap between Progress Bar and Progress String TempX -= ItemSpacing; TempHeight = Y + Height - TempY - (BorderSize / 2.0) - (ItemSpacing / 2.0); // Draw Progress Bar Canvas.SetDrawColor(255, 255, 255, 255); Canvas.SetPos(X + BorderSize, TempY); Canvas.DrawTileStretched(ProgressBarBackground, TempX - BorderSize, TempHeight); Canvas.SetPos(X + BorderSize + 3.0, TempY + 3.0); Canvas.DrawTileStretched(ProgressBarForeground, (TempX - BorderSize - 6.0) * RequirementProgress[CurIndex], TempHeight - 6.0); } function string AddCommas(int Value) { local string StrValue; if ( Value < 1000 ) { return string(Value); } else { if ( Value >= 1000000 ) { StrValue = string(Value / 1000000)$UnitDelimiter; Value = Value % 1000000; if ( Value < 10000 ) { StrValue $= "00"$(Value / 1000); } else if ( Value < 100000 ) { StrValue $= "0"$(Value / 1000); } else { StrValue $= (Value / 1000); } StrValue $= UnitDelimiter; Value = Value % 1000; } else { StrValue = string(Value / 1000)$UnitDelimiter; Value = Value % 1000; } if ( Value < 10 ) { StrValue $= "00"$Value; } else if ( Value < 100 ) { StrValue $= "0"$Value; } else { StrValue $= Value; } } return StrValue; } function string FormatNumber(int Value) { if ( Value < 100000 ) { // Anything less than 100,000 needs no formatting return string(Value); } if ( Value < 1000000 ) { // Anything between 100,000 and 1 million turns into ___K return string(Value / 1000)$OneThousandSuffix; } // Anything over 1 million turns into _._M return string(Value / 1000000)$DecimalPoint$string(int((Value % 1000000) / 100000))$OneMillionSuffix; } function float RequirementHeight(Canvas c) { return (MenuOwner.ActualHeight() / 3.0) - 1.0; } defaultproperties { ItemBorder=0.018000 ProgressBarHeight=0.250000 TextTopOffset=-0.140000 ItemBackground=Texture'KF_InterfaceArt_tex.Menu.Thin_border' ProgressBarBackground=Texture'KF_InterfaceArt_tex.Menu.Innerborder' ProgressBarForeground=Texture'InterfaceArt_tex.Menu.progress_bar' OneThousandSuffix="K" OneMillionSuffix="M" DecimalPoint="." UnitDelimiter="," GetItemHeight=KFPerkProgressList.RequirementHeight FontScale=FNS_Medium } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |