double ResourceProgress(string label, BuildResource br, BuildResource req, bool forward) { double fraction = 1; if (req.amount > 0) { fraction = (req.amount - br.amount) / req.amount; } double required = br.amount; double available = control.padResources.ResourceAmount(br.name); double alarmTime; string percent = (fraction * 100).ToString("G4") + "%"; if (control.paused) { percent = percent + "[paused]"; alarmTime = 0; // need assignment or compiler complains about use of unassigned variable } else { double eta = BuildETA(br, req, forward); alarmTime = Planetarium.GetUniversalTime() + eta; percent = percent + " " + EL_Utils.TimeSpanString(eta); } GUILayout.BeginHorizontal(); // Resource name GUILayout.Box(label, ELStyles.white, GUILayout.Width(125), GUILayout.Height(40)); GUILayout.BeginVertical(); ELStyles.bar.Draw((float)fraction, percent, 300); GUILayout.EndVertical(); // Calculate if we have enough resources to build GUIStyle requiredStyle = ELStyles.green; if (required > available) { requiredStyle = ELStyles.yellow; } // Required and Available GUILayout.Box(displayAmount(required), requiredStyle, GUILayout.Width(100), GUILayout.Height(40)); GUILayout.Box(displayAmount(available), ELStyles.white, GUILayout.Width(100), GUILayout.Height(40)); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return(alarmTime); }
double ResourceProgress(string label, BuildResource br, BuildResource req, bool forward) { double fraction = 1; if (req.amount > 0) { fraction = (req.amount - br.amount) / req.amount; } double required = br.amount; double available = control.padResources.ResourceAmount(br.name); double eta = 0; string percent = (fraction * 100).ToString("G4") + "%"; if (control.paused) { percent = percent + "[paused]"; } else { eta = BuildETA(br, req, forward); percent = percent + " " + EL_Utils.TimeSpanString(eta); } GUILayout.BeginHorizontal(); // Resource name GUILayout.Box(label, ELStyles.white, width125, height40); GUILayout.BeginVertical(); ELStyles.bar.Draw((float)fraction, percent, 300); GUILayout.EndVertical(); // Calculate if we have enough resources to build GUIStyle requiredStyle = ELStyles.green; if (required > available) { requiredStyle = ELStyles.yellow; } // Required and Available GUILayout.Box(displayAmount(required), requiredStyle, width100, height40); GUILayout.Box(displayAmount(available), ELStyles.white, width100, height40); GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); return(eta); }