本文整理汇总了C#中UnityEngine.Rect.AtZero方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.AtZero方法的具体用法?C# Rect.AtZero怎么用?C# Rect.AtZero使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Rect
的用法示例。
在下文中一共展示了Rect.AtZero方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: FillWindow
protected override void FillWindow(Rect inRect)
{
Vector2 vector = new Vector2(inRect.width - 16f, 36f);
Vector2 vector2 = new Vector2(100f, vector.y - 2f);
inRect.height -= 45f;
float num = vector.y + 3f;
List<FileInfo> list = BlueprintFiles.AllFiles.ToList();
float height = (float)list.Count * num;
Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, height);
Rect outRect = new Rect(inRect.AtZero());
outRect.height -= this.bottomAreaHeight;
Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
float num2 = 0f;
int num3 = 0;
foreach (FileInfo current in list)
{
Rect rect = new Rect(0f, num2, vector.x, vector.y);
if (num3 % 2 == 0)
{
Widgets.DrawAltRect(rect);
}
Rect position = rect.ContractedBy(1f);
GUI.BeginGroup(position);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name);
GUI.color = Dialog_Blueprint.ManualSaveTextColor;
Rect rect2 = new Rect(15f, 0f, position.width, position.height);
Text.Anchor = TextAnchor.MiddleLeft;
Text.Font = GameFont.Small;
Widgets.Label(rect2, fileNameWithoutExtension);
GUI.color = Color.white;
Rect rect3 = new Rect(270f, 0f, 200f, position.height);
GUI.color = Color.white;
Text.Anchor = TextAnchor.UpperLeft;
Text.Font = GameFont.Small;
float num4 = vector.x - 2f - vector2.x - vector2.y;
Rect rect4 = new Rect(num4, 0f, vector2.x, vector2.y);
if (Widgets.TextButton(rect4, this.interactButLabel, true, false))
{
this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name));
}
Rect rect5 = new Rect(num4 + vector2.x + 5f, 0f, vector2.y, vector2.y);
if (Widgets.ImageButton(rect5, TexButton.DeleteX))
{
FileInfo localFile = current;
Find.LayerStack.Add(new Dialog_Confirm("ConfirmDelete".Translate(new object[]
{
fileNameWithoutExtension
}), delegate
{
localFile.Delete();
}, true));
}
TooltipHandler.TipRegion(rect5, "DeleteThisSavegame".Translate());
GUI.EndGroup();
num2 += vector.y + 3f;
num3++;
}
Widgets.EndScrollView();
this.DoSpecialSaveLoadGUI(inRect.AtZero());
}
示例2: DoWindowContents
public override void DoWindowContents( Rect inRect )
{
// set up rects
var titleRect = new Rect( inRect.xMin, inRect.yMin, inRect.width, Utilities.TitleHeight );
var listRect = new Rect( inRect.xMin, titleRect.yMax, inRect.width,
inRect.height - Utilities.TitleHeight - Utilities.BottomButtonHeight );
var buttonRect = new Rect( inRect.xMax - 200f, listRect.yMax + Utilities.Margin, 200f,
Utilities.BottomButtonHeight - Utilities.Margin );
// title
Utilities.Label( titleRect, "FMP.IngredientDialogTitle".Translate(), null, TextAnchor.MiddleCenter, 0f, 0f,
GameFont.Medium );
// start recursive list of ingredients
Rect viewRect = listRect.AtZero();
viewRect.height = _finalListHeight;
if ( _finalListHeight > listRect.height )
{
viewRect.width -= 20f; // scrollbar
}
Widgets.DrawMenuSection( listRect );
Widgets.BeginScrollView( listRect, ref _scrollPosition, viewRect );
GUI.BeginGroup( viewRect );
Vector2 cur = Vector2.zero;
foreach ( IngredientSelector ingredient in ingredients )
{
// each selector row draws it's own children recursively.
ingredient.DrawSelectorRow( ref cur, inRect.width, 0, Vector2.zero );
}
GUI.EndGroup();
Widgets.EndScrollView();
_finalListHeight = cur.y + _entryHeight;
// final button
if ( Widgets.ButtonText( buttonRect, "FMP.AddIngredientBills".Translate() ) )
{
foreach ( IngredientSelector ingredient in ingredients )
{
ingredient.AddBills();
}
// we've probably added some bills, so refresh the tab.
manager.ManagerTabs.OfType<ManagerTab_Production>().FirstOrDefault()?.Refresh();
// close this window.
this.Close();
}
}
示例3: DoContent
public void DoContent( Rect canvas )
{
Widgets.DrawMenuSection( canvas );
GUI.BeginGroup( canvas );
canvas = canvas.AtZero();
if ( _selected != null )
{
// bottom buttons
Rect buttonRect = new Rect( canvas.xMax - _button.x, canvas.yMax - _button.y, _button.x - _margin,
_button.y - _margin );
Rect ingredientCheck = new Rect( buttonRect.xMin - 300f - _margin, buttonRect.yMin, 300f,
buttonRect.height );
// add / remove to the stack
if ( Source == SourceOptions.Current )
{
if ( Widgets.TextButton( buttonRect, "FM.Delete".Translate() ) )
{
_selected.Delete();
_selected = null;
Refresh();
return; // just skip to the next tick to avoid null reference errors.
}
TooltipHandler.TipRegion( buttonRect, "FMP.DeleteBillTooltip".Translate() );
}
else
{
if ( _selected.Trigger.IsValid )
{
Widgets.LabelCheckbox(ingredientCheck, "FMP.IngredientDialogTitle".Translate(), ref _selected._createIngredientBills, !_selected._hasMeaningfulIngredientChoices);
if ( Widgets.TextButton( buttonRect, "FM.Manage".Translate() ) )
{
_selected.Managed = true;
Manager.Get.JobStack.Add( _selected );
// refresh source list so that the next added job is not an exact copy.
Refresh();
if ( _selected._hasMeaningfulIngredientChoices &&
_selected._createIngredientBills )
{
Find.WindowStack.Add( new Dialog_CreateJobsForIngredients( _selected.Bill.recipe, _selected.Trigger.Count ) );
}
Source = SourceOptions.Current;
Refresh();
SourceFilter = "";
}
TooltipHandler.TipRegion( buttonRect, "FMP.ManageBillTooltip".Translate() );
}
else
{
GUI.color = new Color( .6f, .6f, .6f );
Widgets.DrawBox( buttonRect );
Utilities.Label( buttonRect, "FMP.NoThreshold".Translate(), "FMP.NoThresholdTooltip".Translate(),
TextAnchor.MiddleCenter );
GUI.color = Color.white;
}
}
// options
Rect optionsColumnRect = new Rect( _margin / 2,
_topAreaHeight,
canvas.width / 2 - _margin,
canvas.height - _topAreaHeight - _margin - _button.y );
Rect recipeColumnRect = new Rect( optionsColumnRect.xMax + _margin,
_topAreaHeight,
canvas.width / 2 - _margin,
canvas.height - _topAreaHeight - _margin - _button.y );
Rect optionsColumnTitle = new Rect( optionsColumnRect.xMin,
0f,
optionsColumnRect.width,
_topAreaHeight );
Rect recipeColumnTitle = new Rect( recipeColumnRect.xMin,
0f,
recipeColumnRect.width,
_topAreaHeight );
// backgrounds
GUI.DrawTexture( optionsColumnRect, Resources.SlightlyDarkBackground );
GUI.DrawTexture( recipeColumnRect, Resources.SlightlyDarkBackground );
// titles
Utilities.Label( optionsColumnTitle, "FMP.Options".Translate(),
anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny );
Utilities.Label( recipeColumnTitle, "FMP.Recipe".Translate(),
anchor: TextAnchor.LowerLeft, lrMargin: _margin * 2, font: GameFont.Tiny );
// options
GUI.BeginGroup( optionsColumnRect );
Vector2 cur = Vector2.zero;
float width = optionsColumnRect.width;
// keep track of optionIndex for shading purposes (lazy way to avoid having to redo this all the damn time).
int optionindex = 0;
// suspended
//.........这里部分代码省略.........
示例4: DoThingFilterConfigWindow
public void DoThingFilterConfigWindow( Rect canvas, ref Vector2 scrollPosition, ThingFilter filter,
ThingFilter parentFilter = null, int openMask = 1,
bool buttonsAtBottom = false )
{
// respect your bounds!
GUI.BeginGroup( canvas );
canvas = canvas.AtZero();
// set up buttons
Text.Font = GameFont.Tiny;
float width = canvas.width - 2f;
var clearButtonRect = new Rect( canvas.x + 1f, canvas.y + 1f, width / 2f, 24f );
var allButtonRect = new Rect( clearButtonRect.xMax + 1f, clearButtonRect.y, width / 2f, 24f );
// offset canvas position for buttons.
if ( buttonsAtBottom )
{
clearButtonRect.y = canvas.height - clearButtonRect.height;
allButtonRect.y = canvas.height - clearButtonRect.height;
canvas.yMax -= clearButtonRect.height;
}
else
{
canvas.yMin = clearButtonRect.height;
}
// draw buttons + logic
if ( Widgets.ButtonTextSubtle( clearButtonRect, "ClearAll".Translate() ) )
{
filter.SetDisallowAll();
}
if ( Widgets.ButtonTextSubtle( allButtonRect, "AllowAll".Translate() ) )
{
filter.SetAllowAll( parentFilter );
}
Text.Font = GameFont.Small;
// do list
var curY = 2f;
var viewRect = new Rect( 0f, 0f, canvas.width - 16f, viewHeight );
// scrollview
Widgets.BeginScrollView( canvas, ref scrollPosition, viewRect );
// slider(s)
DrawHitPointsFilterConfig( ref curY, viewRect.width, filter );
DrawQualityFilterConfig( ref curY, viewRect.width, filter );
// main listing
var listingRect = new Rect( 0f, curY, viewRect.width, 9999f );
var listingTreeThingFilter = new Listing_TreeThingFilter( listingRect, filter, parentFilter, null, null );
TreeNode_ThingCategory node = ThingCategoryNodeDatabase.RootNode;
if ( parentFilter != null )
{
if ( parentFilter.DisplayRootCategory == null )
{
parentFilter.RecalculateDisplayRootCategory();
}
node = parentFilter.DisplayRootCategory;
}
// draw the actual thing
listingTreeThingFilter.DoCategoryChildren( node, 0, openMask, true );
listingTreeThingFilter.End();
// update height.
viewHeight = curY + listingTreeThingFilter.CurHeight;
Widgets.EndScrollView();
GUI.EndGroup();
}
示例5: DoWindowContents
public override void DoWindowContents( Rect inRect )
{
base.DoWindowContents( inRect );
var topWidth = 2 * 24f + 4f;
var topRect = new Rect( ( inRect.width - topWidth ) / 2.0f, 0.0f, 24.0f, 24.0f );
if( CCL_Widgets.ButtonImage( topRect, Data.Icons.WorkAssignments, "W", Data.Strings.SlaveWorkAssignments.Translate() ) )
{
CurrentTab = SlaveTabs.WorkAssignment;
}
topRect.x += 24f + 4f;
if( CCL_Widgets.ButtonImage( topRect, Data.Icons.Restrictions, "A", Data.Strings.SlaveRestrictions.Translate() ) )
{
CurrentTab = SlaveTabs.TimeTable;
}
topRect.x += 24f + 4f;
var subRect = new Rect( 0.0f, 24.0f + 16.0f, inRect.width, inRect.height - 24.0f - 4.0f );
GUI.BeginGroup( subRect );
{
switch( CurrentTab )
{
case SlaveTabs.WorkAssignment:
DoWindowContents_WorkAssignments( subRect.AtZero() );
break;
case SlaveTabs.TimeTable:
DoWindowContents_Restrictions( subRect.AtZero() );
break;
}
}
GUI.EndGroup();
}
示例6: DrawSelectionArea
private void DrawSelectionArea(Rect rect)
{
try
{
Widgets.DrawMenuSection(rect);
GUI.BeginGroup(rect);
Rect outRect = rect.AtZero();
float height = _cachedHelpCategories.Sum((c) => c.DrawHeight);
Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, height);
float curY = outRect.y;
Widgets.BeginScrollView(outRect, ref selectionScrollPos, viewRect);
if (_cachedHelpCategories.Count < 1)
{
Rect messageRect = outRect.AtZero();
Widgets.Label(messageRect, "NoHelpDefs".Translate());
}
else
{
foreach (var m in _cachedHelpCategories)
{
Rect entryRect = new Rect(0f, curY, viewRect.width, m.DrawHeight);
DrawModCategory(entryRect, m);
curY += m.DrawHeight;
}
}
}
catch (Exception e)
{
Log.Error("Exception while drawing selection error: \n" + e.ToString());
}
finally
{
Widgets.EndScrollView();
GUI.EndGroup();
}
}
示例7: DoContent
private void DoContent( Rect rect )
{
// cop out if nothing is selected.
if ( _selectedCurrent == null )
{
return;
}
// background
Widgets.DrawMenuSection( rect );
// begin window
GUI.BeginGroup( rect );
rect = rect.AtZero();
// rects
var optionsColumnRect = new Rect( Utilities.Margin / 2,
_topAreaHeight,
rect.width / 2 - Utilities.Margin,
rect.height - _topAreaHeight - Utilities.Margin - Utilities.ButtonSize.y );
var animalsRect = new Rect( optionsColumnRect.xMax + Utilities.Margin,
_topAreaHeight,
rect.width / 2 - Utilities.Margin,
rect.height - _topAreaHeight - Utilities.Margin - Utilities.ButtonSize.y );
var optionsColumnTitle = new Rect( optionsColumnRect.xMin,
0f,
optionsColumnRect.width,
_topAreaHeight );
var animalsColumnTitle = new Rect( animalsRect.xMin,
0f,
animalsRect.width,
_topAreaHeight );
// backgrounds
GUI.DrawTexture( optionsColumnRect, Resources.SlightlyDarkBackground );
GUI.DrawTexture( animalsRect, Resources.SlightlyDarkBackground );
// titles
Utilities.Label( optionsColumnTitle, "FMP.Options".Translate(),
anchor: TextAnchor.LowerLeft, lrMargin: Utilities.Margin * 2, font: GameFont.Tiny );
Utilities.Label( animalsColumnTitle, "FML.Animals".Translate(),
anchor: TextAnchor.LowerLeft, lrMargin: Utilities.Margin * 2, font: GameFont.Tiny );
// options
GUI.BeginGroup( optionsColumnRect );
Vector2 cur = Vector2.zero;
var optionIndex = 1;
// counts header
Utilities.Label( ref cur, optionsColumnRect.width, _entryHeight, "FML.TargetCounts".Translate(),
alt: optionIndex % 2 == 0 );
// counts table
var cols = 3;
float fifth = optionsColumnRect.width / 5;
float[] widths = {fifth, fifth * 2, fifth * 2};
float[] heights = {_entryHeight / 3 * 2, _entryHeight, _entryHeight};
// set up a 3x3 table of rects
var countRects = new Rect[cols, cols];
for ( var x = 0; x < cols; x++ )
{
for ( var y = 0; y < cols; y++ )
{
// kindof overkill for a 3x3 table, but ok.
countRects[x, y] = new Rect( widths.Take( x ).Sum(), cur.y + heights.Take( y ).Sum(), widths[x],
heights[y] );
if ( optionIndex % 2 == 0 )
{
Widgets.DrawAltRect( countRects[x, y] );
}
}
}
optionIndex++;
// headers
Utilities.Label( countRects[1, 0], Gender.Female.ToString(), null, TextAnchor.LowerCenter,
font: GameFont.Tiny );
Utilities.Label( countRects[2, 0], Gender.Male.ToString(), null, TextAnchor.LowerCenter, font: GameFont.Tiny );
Utilities.Label( countRects[0, 1], "FML.Adult".Translate(), null, TextAnchor.MiddleRight,
font: GameFont.Tiny );
Utilities.Label( countRects[0, 2], "FML.Juvenile".Translate(), null, TextAnchor.MiddleRight,
font: GameFont.Tiny );
// fields
DoCountField( countRects[1, 1], Utilities_Livestock.AgeAndSex.AdultFemale );
DoCountField( countRects[2, 1], Utilities_Livestock.AgeAndSex.AdultMale );
DoCountField( countRects[1, 2], Utilities_Livestock.AgeAndSex.JuvenileFemale );
DoCountField( countRects[2, 2], Utilities_Livestock.AgeAndSex.JuvenileMale );
cur.y += 3 * _entryHeight;
// restrict to area
var restrictAreaRect = new Rect( cur.x, cur.y, optionsColumnRect.width, _entryHeight );
if ( optionIndex % 2 == 0 )
{
Widgets.DrawAltRect( restrictAreaRect );
}
Utilities.DrawToggle( restrictAreaRect, "FML.RestrictToArea".Translate(),
ref _selectedCurrent.RestrictToArea );
//.........这里部分代码省略.........
示例8: FillWindow
protected override void FillWindow(Rect inRect)
{
base.FillWindow(inRect);
//First we draw the header
Text.Font = GameFont.Medium;
Text.Anchor = TextAnchor.UpperCenter;
Widgets.Label(new Rect(0f, 0f, 300f, 300f), "ManufacturingPlant".Translate());
Text.Anchor = TextAnchor.UpperLeft;
//This float is used to set the padding at the bottom of the window.
float bottomPaddingHeight = 50f;
//The mainRect is the rectangle which contains the listbox
Rect mainRect = new Rect(0f, bottomPaddingHeight, inRect.width, inRect.height - bottomPaddingHeight - 50f);
//We initialise the entry and button sizes according to the main rect, which is sized depending on the window size. This lets the window be resized easily without (hoepfully) creating too many problems.
this.lineEntrySize = new Vector2(mainRect.width - 16f, 100f);
this.interactButtonSize = new Vector2(100f, this.lineEntrySize.y / 2 - 14f);
//We begin the group to tell the system that the following elements are grouped together.
GUI.BeginGroup(mainRect);
//This float is the height of the entry with a small margin added to it.
float entryHeightWithMargin = this.lineEntrySize.y + 8f;
//This float is the height of the entire list with all included entries and margins. This is used for the rect which houses all the entries, even though we wont see all of them at once.
float height = (float)assemblyLines.Count * entryHeightWithMargin;
//This rect is used inside the scroll view, and is moved up and down to show the entries.
Rect viewRect = new Rect(0f, 0f, mainRect.width - 16f, height);
//This is the rect on the screen to be used for the ScrollView
Rect outRect = new Rect(mainRect.AtZero());
//This function starts the scrolling view, and uses the scrollPosition variable to record where in the scrollview we are looking
Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
//This float is the current y position in the scrollview, we use this for drawing each entry under each other.
float currentY = 0f;
//We first check to see if there are any entries. If no, then give a small message
if (assemblyLines.Count == 0)
{
Rect rect2 = new Rect(0f, currentY, this.lineEntrySize.x, this.lineEntrySize.y);
Text.Font = GameFont.Small;
Widgets.Label(rect2, "NoAssemblyLines".Translate());
}
//If there are entries, then we draw the entry for each element in the list, calling our Draw...() function.
else
{
foreach (AssemblyLine line in assemblyLines)
{
line.OnGUI(currentY, this.lineEntrySize, this.interactButtonSize, this);
//Increment the current y position for the next entry to be drawn
currentY += entryHeightWithMargin;
}
}
//Must remember to end the view once it has been drawn.
Widgets.EndScrollView();
//Likewise, remember to end the group
GUI.EndGroup();
//This draws the button in the bottom right corner of the window. It uses the same size as the Close button
Rect lineManagerButRect = new Rect(inRect.width - this.lineManagerButtonSize.x, inRect.height - this.lineManagerButtonSize.y, this.lineManagerButtonSize.x, this.lineManagerButtonSize.y);
if (Widgets.TextButton(lineManagerButRect, "ConstructNewAssemblyLine".Translate()))
{
if (MPmanager.manager.CanAddAssemblyLine)
{
string costString = "";
if (Game.GodMode && AssemblyLine.Settings.instaBuild)
costString = "Nothing".Translate();
else
{
foreach (var item in AssemblyLine.Settings.BuildingCost)
{
costString += string.Format("{1} {0}\n", item.thing.label, item.amount);
}
}
Find.LayerStack.Add(new Dialog_Confirm("BuildNewAssemblyLineDialog".Translate(costString, TicksToTime.GetTime((float)AssemblyLine.ConstructionTicksRequired)), delegate
{
MPmanager.manager.AddNewAssemblyLine((Game.GodMode && AssemblyLine.Settings.instaBuild));
}));
}
else
{
Dialog_Message m = new Dialog_Message("MaximumAssemblyLines".Translate());
Find.LayerStack.Add(m);
SoundDefOf.ClickReject.PlayOneShot(SoundInfo.OnCamera());
}
}
}
示例9: DrawRecipeList
private void DrawRecipeList(Rect inRect)
{
Rect availableRecipeMainRect = new Rect(0f, currentYMaxLeft, availableRecipeMainRectSize.x, availableRecipeMainRectSize.y);
this.bottom = availableRecipeMainRect.yMax;
this.recipeEntrySize = new Vector2(availableRecipeMainRect.width - 16f, 48f);
this.recipeAddButtonSize = new Vector2(120f, this.recipeEntrySize.y - 12f);
Widgets.DrawMenuSection(availableRecipeMainRect);
GUI.BeginGroup(availableRecipeMainRect);
if (enteredText != "")
{
list = (
from t in this.recipesList
where t.label.ToLower().Contains(enteredText.ToLower())
select t).ToList();
}
else
{
list = this.recipesList;
}
float entryHeight = this.recipeEntrySize.y;
float height = (float)list.Count * entryHeight;
Rect viewRect = new Rect(0f, 0f, availableRecipeMainRect.width - 16f, height);
Rect outRect = new Rect(availableRecipeMainRect.AtZero());
Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
float currentY = 0f;
float num3 = 0f;
if (recipesList.Count == 0)
{
Rect rect = new Rect(0f, currentY, this.recipeEntrySize.x, this.recipeEntrySize.y);
Text.Font = GameFont.Small;
Widgets.Label(rect, "NoRecipesFound".Translate());
}
else
{
foreach (RecipeDef def in list)
{
Rect rect2 = new Rect(0f, currentY, this.recipeEntrySize.x, this.recipeEntrySize.y);
if ((rect2.Contains(Event.current.mousePosition)) || (selectedDef != null && def == selectedDef))
{
GUI.color = MouseHoverColor;
GUI.DrawTexture(rect2, BaseContent.WhiteTex);
}
else if (num3 % 2 == 0)
{
GUI.DrawTexture(rect2, AltTexture);
}
Rect innerRect = rect2.ContractedBy(3f);
GUI.BeginGroup(innerRect);
string recipeName = def.label.CapitalizeFirst();
GUI.color = Color.white;
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.MiddleLeft;
Rect rect = new Rect(15f, 0f, innerRect.width, innerRect.height);
Widgets.Label(rect, recipeName);
float buttonX = recipeEntrySize.x - 6f - recipeAddButtonSize.x;
Rect butRect = new Rect(buttonX, 0f, recipeAddButtonSize.x, recipeAddButtonSize.y);
if (Widgets.InvisibleButton(rect))
{
this.selectedDef = def;
this.config = new OrderConfig(def);
//Log.Message("Clicked " + def.defName);
}
GUI.EndGroup();
currentY += entryHeight;
num3++;
}
}
GUI.EndGroup();
Text.Anchor = TextAnchor.UpperLeft;
Widgets.EndScrollView();
}
示例10: FillWindow
protected override void FillWindow(Rect inRect)
{
base.FillWindow(inRect);
bottomLine = CloseButSize.y + margin;
float m = 15f;
maxXHorizontalLeft = inRect.width / 2 - m;
minXHorizontalRight = inRect.width / 2 + m;
if (Widgets.TextButton(new Rect(0f, inRect.height - buttonSize.y, buttonSize.x, buttonSize.y), "Back"))
{
this.Close();
Find.LayerStack.Add(previousPage);
}
Rect labelRect = new Rect(0f, 0f, inRect.width, 30f);
curYLeft += labelRect.yMax + margin;
Text.Font = GameFont.Medium;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(labelRect, line.label);
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;
Widgets.DrawLineHorizontal(0, curYLeft, inRect.width);
curYLeft += 10f;
curYRight += curYLeft;
//Draw the list box of all orders
float rectheight = inRect.height - curYLeft - bottomLine;
orderStackRect = new Rect(0f, curYLeft, maxXHorizontalLeft, rectheight);
if (line.OrderStack.Count <= 0)
{
Text.Font = GameFont.Medium;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(orderStackRect, "NoOrders".Translate());
Text.Font = GameFont.Small;
Text.Anchor = TextAnchor.UpperLeft;
}
else
{
this.orderEntrySize = new Vector2(orderStackRect.width - 16f, 120f);
try
{
GUI.BeginGroup(orderStackRect);
float entryHeightWithMargin = orderEntrySize.y + 8f;
float height = (float)line.OrderStack.Count * entryHeightWithMargin;
Rect viewRect = new Rect(0f, 0f, orderEntrySize.x, height);
Rect outRect = new Rect(orderStackRect.AtZero());
try
{
Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
float currentScrollY = 0f;
foreach (var current in this.orders)
{
DrawOrderEntry(current, currentScrollY);
currentScrollY += entryHeightWithMargin;
}
}
finally
{
Widgets.EndScrollView();
}
}
finally
{
GUI.EndGroup();
}
}
//Draw the options buttons on the right side
float paddingBetweenButtons = 12f;
Vector2 optionsRectSize = new Vector2(inRect.width - minXHorizontalRight, CloseButSize.y * 2 + paddingBetweenButtons + 4f);
Rect optionsButtonsRect = new Rect(minXHorizontalRight, curYRight, optionsRectSize.x, optionsRectSize.y);
curYRight += optionsRectSize.y + 6f;
Widgets.DrawMenuSection(optionsButtonsRect);
Rect innerOptions = optionsButtonsRect.ContractedBy(2f);
try
{
GUI.BeginGroup(innerOptions);
float buttonXSize = (innerOptions.width / 2) - paddingBetweenButtons / 2;
//float butY = innerOptions.height / 2 - (this.CloseButSize.y / 2);
float butY = CloseButSize.y / 2;
float butY2 = innerOptions.height - (this.CloseButSize.y + (CloseButSize.y / 2));
//Add recipe button
Rect recipeButtonRect = new Rect(0f, innerOptions.height / 2 - CloseButSize.y / 2, buttonXSize, CloseButSize.y);
if (Widgets.TextButton(recipeButtonRect, "AddOrder".Translate()))
{
Find.LayerStack.Add(new Page_RecipeManagement(line, this));
}
//Options button
//Rect optionsButtonRect = new Rect(innerOptions.width - buttonXSize, 0f, buttonXSize, CloseButSize.y);
//Widgets.TextButton(optionsButtonRect, "MD2Options".Translate());
//Upgrades button
Rect upgradesButtonRect = new Rect(innerOptions.width-buttonXSize, innerOptions.height /2 - CloseButSize.y/2, buttonXSize, CloseButSize.y);
if (Widgets.TextButton(upgradesButtonRect, "Upgrades".Translate()))
{
Find.LayerStack.Add(new Dialog_UpgradeManager(this.line));
//.........这里部分代码省略.........
示例11: DrawFileEntry
private void DrawFileEntry( Rect rect, SaveFileInfo file )
{
GUI.BeginGroup( rect );
// set up rects
Rect nameRect = rect.AtZero();
nameRect.width -= 200f + _iconSize + 4 * _margin;
nameRect.xMin += _margin;
Rect timeRect = new Rect( nameRect.xMax + _margin, 0f, 100f, rect.height );
Rect buttonRect = new Rect( timeRect.xMax + _margin, 1f, 100f, rect.height - 2f );
Rect deleteRect = new Rect( buttonRect.xMax + _margin, ( rect.height - _iconSize ) / 2, _iconSize, _iconSize );
// name
Text.Anchor = TextAnchor.MiddleLeft;
Widgets.Label( nameRect, Path.GetFileNameWithoutExtension( file.FileInfo.Name ) );
Text.Anchor = TextAnchor.UpperLeft;
// timestamp
GUI.color = Color.gray;
Dialog_MapList.DrawDateAndVersion( file, timeRect );
Text.Font = GameFont.Small;
GUI.color = Color.white;
// load button
if ( Widgets.TextButton( buttonRect, "FM.Import".Translate() ) )
{
TryImport( file );
}
// delete button
if ( Widgets.ImageButton( deleteRect, Resources.DeleteX ) )
{
Find.WindowStack.Add( new Dialog_Confirm( "ConfirmDelete".Translate( file.FileInfo.Name ), delegate
{
file.FileInfo.Delete();
Refresh();
}, true ) );
}
GUI.EndGroup();
}
示例12: DrawSelectionArea
void DrawSelectionArea(Rect rect)
{
Widgets.DrawMenuSection(rect);
GUI.BeginGroup(rect);
Rect outRect = rect.AtZero();
float height = _cachedHelpCategories.Sum(c => c.DrawHeight);
var viewRect = new Rect(0f, 0f, outRect.width - 16f, height);
float curY = outRect.y;
Widgets.BeginScrollView(outRect, ref selectionScrollPos, viewRect);
if (_cachedHelpCategories.Count < 1)
{
Rect messageRect = outRect.AtZero();
Widgets.Label(messageRect, "NoHelpDefs".Translate());
}
else
{
foreach (var m in _cachedHelpCategories)
{
var entryRect = new Rect(0f, curY, viewRect.width, m.DrawHeight);
DrawModCategory(entryRect, m);
curY += m.DrawHeight;
}
}
Widgets.EndScrollView();
GUI.EndGroup();
}
示例13: DoWindowContents
/// <summary>
/// Draws the mod configuration window contents.
/// </summary>
/// <returns>The final height of the window rect.</returns>
/// <param name="rect">Rect</param>
public override float DoWindowContents( Rect rect )
{
var listing = new Listing_Standard( rect );
{
listing.ColumnWidth = rect.width - 4f;
#region Main Toggle
var toggleLabel = "MiniMap.MCMToggleMain".Translate();
listing.CheckboxLabeled( toggleLabel, ref MiniMap.MiniMapController.visible );
listing.Gap();
#endregion
#region Handle all MiniMaps and Overlays
foreach( var minimap in Controller.Data.MiniMaps )
{
if( minimap.IsOrHasIConfigurable )
{
var iMinimap = minimap as IConfigurable;
#region Minimap Header
MinimapHeader( listing, minimap );
#endregion
#region Handle MiniMap IConfigurable
if( iMinimap != null )
{
#region Minimap IConfigurable
var iMinimapRect = new Rect( listing.Indentation(), listing.CurHeight, listing.ColumnWidth, 9999f );
GUI.BeginGroup( iMinimapRect );
var iMinimapHeight = iMinimap.DrawMCMRegion( iMinimapRect.AtZero() );
GUI.EndGroup();
listing.Gap( iMinimapHeight + 6f );
#endregion
}
#endregion
#region Handle all MiniMap Overlays
foreach( var overlay in minimap.overlayWorkers )
{
var iOverlay = overlay as IConfigurable;
#region Handle Overlay IConfigurable
if( iOverlay != null )
{
#region Overlay Header
OverlayHeader( listing, overlay );
#endregion
#region Overlay IConfigurable
var iOverlayRect = new Rect( listing.Indentation(), listing.CurHeight, listing.ColumnWidth, 9999f );
GUI.BeginGroup( iOverlayRect );
var iOverlayHeight = iOverlay.DrawMCMRegion( iOverlayRect.AtZero() );
GUI.EndGroup();
listing.Gap( iOverlayHeight + 6f );
listing.Undent();
#endregion
}
#endregion
}
#endregion
#region Final Undentation
listing.Gap();
listing.Undent();
#endregion
}
}
#endregion
}
listing.End();
return listing.CurHeight;
}
示例14: FillWindow
protected override void FillWindow(Rect inRect)
{
Vector2 vector = new Vector2(inRect.width - 16f, 48f);
Vector2 vector2 = new Vector2(100f, vector.y - 12f);
inRect.height -= 45f;
List<FileInfo> list = SaveFiles.AllSaveFiles.ToList<FileInfo>();
float num = vector.y + 8f;
float height = (float)list.Count * num;
Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, height);
Rect position = new Rect(inRect.AtZero());
position.height -= this.bottomAreaHeight;
this.scrollPosition = GUI.BeginScrollView(position, this.scrollPosition, viewRect);
float num2 = 0f;
foreach (FileInfo current in list)
{
Rect rect = new Rect(0f, num2, vector.x, vector.y);
Widgets.DrawMenuSection(rect);
Rect innerRect = rect.GetInnerRect(6f);
GUI.BeginGroup(innerRect);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name);
if (MapFiles.IsAutoSave(fileNameWithoutExtension))
{
GUI.color = DialogList.AutosaveTextColor;
}
else
{
GUI.color = DialogList.ManualSaveTextColor;
}
Rect position2 = new Rect(15f, 0f, innerRect.width, innerRect.height);
GUI.skin.label.alignment = TextAnchor.MiddleLeft;
GenFont.SetFontSmall();
GUI.Label(position2, fileNameWithoutExtension);
GUI.color = Color.white;
Rect position3 = new Rect(220f, 0f, innerRect.width, innerRect.height);
GenFont.SetFontTiny();
GUI.color = new Color(1f, 1f, 1f, 0.5f);
GUI.Label(position3, current.LastWriteTime.ToString());
GUI.color = Color.white;
GUI.skin.label.alignment = TextAnchor.UpperLeft;
GenFont.SetFontSmall();
float num3 = vector.x - 12f - vector2.x - vector2.y;
Rect butRect = new Rect(num3, 0f, vector2.x, vector2.y);
if (Widgets.TextButton(butRect, this.interactButLabel))
{
this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name));
}
Rect rect2 = new Rect(num3 + vector2.x + 5f, 0f, vector2.y, vector2.y);
if (Widgets.ImageButton(rect2, ButtonText.DeleteX))
{
FileInfo localFile = current;
Find.UIRoot.layers.Add(new Dialog_Confirm("ConfirmDelete".Translate(new object[]
{
localFile.Name
}), delegate
{
localFile.Delete();
}, true));
}
TooltipHandler.TipRegion(rect2, "DeleteThisSavegame".Translate());
GUI.EndGroup();
num2 += vector.y + 8f;
}
GUI.EndScrollView();
this.DoSpecialSaveLoadGUI(inRect.AtZero());
}
示例15: DoWindowContents
public override void DoWindowContents( Rect inRect )
{
// Close if work tab closed
if( Find.WindowStack.WindowOfType<MainTabWindow_Work>() == null )
{
Find.WindowStack.TryRemove( this );
}
float areaHeight = (inRect.height - 50f - _margin)/2f;
// the space reserved on the UI
Rect headerRect = new Rect(inRect.xMin, _margin, inRect.width, 50f - _margin);
Rect workTypeListRect = new Rect(inRect.xMin, 50f, inRect.width, areaHeight);
Rect workGiverListRect = new Rect(inRect.xMin, workTypeListRect.yMax + _margin, inRect.width, areaHeight);
// leave room for buttons
workGiverListRect.width -= _buttonSize.x + _margin;
workTypeListRect.width -= _buttonSize.x + _margin;
// button areas
Rect workTypeSortRect = new Rect(workTypeListRect.xMax + _margin, workTypeListRect.yMin, _buttonSize.x, areaHeight);
Rect workGiverSortRect = new Rect(workGiverListRect.xMax + _margin, workGiverListRect.yMin, _buttonSize.x, areaHeight);
Rect resetRect = new Rect(inRect.width - 27f, 13f - _margin / 2, 24f, 24f);
// draw backgrounds
Widgets.DrawMenuSection( workTypeListRect );
Widgets.DrawMenuSection( workGiverListRect );
// leave a tiny margin around the scrollbar if necessary
if (_workTypeListHeight > workTypeListRect.height)
{
workTypeListRect.xMax -= 2f;
}
if( _workGiverListHeight > workGiverListRect.height )
{
workGiverListRect.xMax -= 2f;
}
// the canvas for the (scrollable) lists
Rect workTypeListContent = new Rect(workTypeListRect.AtZero());
Rect workGiverListContent = new Rect(workGiverListRect.AtZero());
// set height to calculated height after first (every) pass.
workTypeListContent.height = _workTypeListHeight;
workGiverListContent.height = _workGiverListHeight;
// leave room for scrollbar if necessary.
workTypeListContent.width -= _workTypeListHeight > workTypeListRect.height ? 16f : 0f;
workGiverListContent.width -= _workGiverListHeight > workGiverListRect.height ? 16f : 0f;
// header
Text.Font = GameFont.Medium;
Widgets.Label(headerRect, "Fluffy.WorkPrioritiesDetails".Translate() );
Text.Font = GameFont.Small;
// reset button
TooltipHandler.TipRegion(resetRect, "Fluffy.ResetPriorities".Translate());
if (Widgets.ImageButton(resetRect, ResetButton))
{
MapComponent_Priorities.ResetPriorities();
RebuildWorkTypeDefsList();
}
// worktype lister
GUI.BeginGroup( workTypeListRect );
Widgets.BeginScrollView( workTypeListRect.AtZero(), ref _workTypeScrollPosition, workTypeListContent );
// keep track of position
Vector2 cur = Vector2.zero;
// draw the listings
foreach (WorkTypeDef workType in WorkTypeDefs)
{
// move with selected when reordering
if (_workTypeMoved && workType == _selectedWorkTypeDef)
{
_workTypeScrollPosition.y = cur.y - 2 * _entryHeight;
_workTypeMoved = false;
}
if (DrawEntry(ref cur, workTypeListContent, workType == _selectedWorkTypeDef, workType))
{
_selectedWorkTypeDef = workType;
_selectedWorkGiverDef = null;
}
}
// set the actual height after having drawn everything
_workTypeListHeight = cur.y;
Widgets.EndScrollView();
GUI.EndGroup();
// draw buttons
DrawSortButtons( workTypeSortRect, _selectedWorkTypeDef != null, _selectedWorkTypeDef );
// START WORKGIVERS
if( _selectedWorkTypeDef != null)
{
// workgiver lister
//.........这里部分代码省略.........