Unify the perf info visibility

This commit is contained in:
Paul Chote
2010-04-11 17:13:29 +12:00
parent a75d173371
commit a89f576fb9
9 changed files with 17 additions and 45 deletions

View File

@@ -25,8 +25,7 @@ namespace OpenRA.GameRules
// Debug settings // Debug settings
public bool UnitDebug = false; public bool UnitDebug = false;
public bool PathDebug = false; public bool PathDebug = false;
public bool PerfGraph = true; public bool PerfDebug = true;
public bool PerfText = true;
public bool IndexDebug = false; public bool IndexDebug = false;
// Window settings // Window settings

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Widgets
public readonly string Background = "dialog"; public readonly string Background = "dialog";
public override void Draw(World world) public override void Draw(World world)
{ {
if (!Visible) if (!IsVisible())
{ {
base.Draw(world); base.Draw(world);
return; return;

View File

@@ -63,7 +63,7 @@ namespace OpenRA.Widgets
public override void Draw(World world) public override void Draw(World world)
{ {
if (!Visible) if (!IsVisible())
{ {
base.Draw(world); base.Draw(world);
return; return;

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Widgets
public override void Draw(World world) public override void Draw(World world)
{ {
if (!Visible) if (!IsVisible())
{ {
base.Draw(world); base.Draw(world);
return; return;

View File

@@ -29,6 +29,7 @@ namespace OpenRA.Widgets.Delegates
{ {
var r = Chrome.rootWidget; var r = Chrome.rootWidget;
var perfRoot = r.GetWidget("PERF_BG"); var perfRoot = r.GetWidget("PERF_BG");
perfRoot.IsVisible = () => {return (perfRoot.Visible && Game.Settings.PerfDebug);};
// Perf text // Perf text
var perfText = perfRoot.GetWidget<LabelWidget>("TEXT"); var perfText = perfRoot.GetWidget<LabelWidget>("TEXT");
@@ -40,11 +41,6 @@ namespace OpenRA.Widgets.Delegates
PerfHistory.items["tick_time"].LastValue, PerfHistory.items["tick_time"].LastValue,
Game.LocalTick); Game.LocalTick);
}; };
perfText.IsVisible = () => {return (perfText.Visible && Game.Settings.PerfText);};
// Perf graph
var perfGraph = perfRoot.GetWidget("GRAPH");
perfGraph.IsVisible = () => {return (perfGraph.Visible && Game.Settings.PerfGraph);};
} }
} }
} }

View File

@@ -30,19 +30,12 @@ namespace OpenRA.Widgets.Delegates
return true; return true;
}; };
r.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PERFGRAPH").Checked = () => {return Game.Settings.PerfGraph;}; r.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PERFDEBUG").Checked = () => {return Game.Settings.PerfDebug;};
r.GetWidget("SETTINGS_CHECKBOX_PERFGRAPH").OnMouseDown = mi => { r.GetWidget("SETTINGS_CHECKBOX_PERFDEBUG").OnMouseDown = mi => {
Game.Settings.PerfGraph = !Game.Settings.PerfGraph; Game.Settings.PerfDebug = !Game.Settings.PerfDebug;
return true; return true;
}; };
r.GetWidget<CheckboxWidget>("SETTINGS_CHECKBOX_PERFTEXT").Checked = () => {return Game.Settings.PerfText;};
r.GetWidget("SETTINGS_CHECKBOX_PERFTEXT").OnMouseDown = mi => {
Game.Settings.PerfText = !Game.Settings.PerfText;
return true;
};
// Menu Buttons // Menu Buttons
r.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => { r.GetWidget("MAINMENU_BUTTON_SETTINGS").OnMouseUp = mi => {
r.ShowMenu("SETTINGS_BG"); r.ShowMenu("SETTINGS_BG");

View File

@@ -107,7 +107,7 @@ namespace OpenRA.Widgets
public virtual bool HandleInput(MouseInput mi) public virtual bool HandleInput(MouseInput mi)
{ {
// Are we able to handle this event? // Are we able to handle this event?
if (!Visible || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y)) if (!IsVisible() || !GetEventBounds().Contains(mi.Location.X,mi.Location.Y))
return false; return false;
// Can any of our children handle this? // Can any of our children handle this?
@@ -131,7 +131,7 @@ namespace OpenRA.Widgets
public virtual void Draw(World world) public virtual void Draw(World world)
{ {
if (Visible) if (IsVisible())
foreach (var child in Children) foreach (var child in Children)
child.Draw(world); child.Draw(world);
} }

View File

@@ -121,20 +121,13 @@ Container:
Width:300 Width:300
Height:20 Height:20
Text:Show Spatial Index Debug Text:Show Spatial Index Debug
Checkbox@SETTINGS_CHECKBOX_PERFGRAPH: Checkbox@SETTINGS_CHECKBOX_PERFDEBUG:
Id:SETTINGS_CHECKBOX_PERFGRAPH Id:SETTINGS_CHECKBOX_PERFDEBUG
X:100 X:100
Y:150 Y:150
Width:300 Width:300
Height:20 Height:20
Text:Show Performance Graph Text:Show Performance Information
Checkbox@SETTINGS_CHECKBOX_PERFTEXT:
Id:SETTINGS_CHECKBOX_PERFTEXT
X:100
Y:180
Width:300
Height:20
Text:Show Performance Text
Button@SETTINGS_BUTTON_OK: Button@SETTINGS_BUTTON_OK:
Id:SETTINGS_BUTTON_OK Id:SETTINGS_BUTTON_OK
X:PARENT_RIGHT - 180 X:PARENT_RIGHT - 180
@@ -306,7 +299,6 @@ Container:
Y:WINDOW_BOTTOM - 250 Y:WINDOW_BOTTOM - 250
Width: 210 Width: 210
Height: 250 Height: 250
Visible: true
Children: Children:
PerfGraph@GRAPH: PerfGraph@GRAPH:
ClickThrough:true ClickThrough:true

View File

@@ -121,20 +121,13 @@ Container:
Width:300 Width:300
Height:20 Height:20
Text:Show Spatial Index Debug Text:Show Spatial Index Debug
Checkbox@SETTINGS_CHECKBOX_PERFGRAPH: Checkbox@SETTINGS_CHECKBOX_PERFDEBUG:
Id:SETTINGS_CHECKBOX_PERFGRAPH Id:SETTINGS_CHECKBOX_PERFDEBUG
X:100 X:100
Y:150 Y:150
Width:300 Width:300
Height:20 Height:20
Text:Show Performance Graph Text:Show Performance Information
Checkbox@SETTINGS_CHECKBOX_PERFTEXT:
Id:SETTINGS_CHECKBOX_PERFTEXT
X:100
Y:180
Width:300
Height:20
Text:Show Performance Text
Button@SETTINGS_BUTTON_OK: Button@SETTINGS_BUTTON_OK:
Id:SETTINGS_BUTTON_OK Id:SETTINGS_BUTTON_OK
X:PARENT_RIGHT - 180 X:PARENT_RIGHT - 180
@@ -306,7 +299,6 @@ Container:
Y:WINDOW_BOTTOM - 250 Y:WINDOW_BOTTOM - 250
Width: 210 Width: 210
Height: 250 Height: 250
Visible: true
Children: Children:
PerfGraph@GRAPH: PerfGraph@GRAPH:
ClickThrough:true ClickThrough:true