/// <summary>
 /// Adds the 'Show Moves' button to the specified ShortcutBar
 /// </summary>
 /// <param name="shortcutBar">The ShortcutBar to add the button to</param>
 public static void AddShowMovesButtonToBar(Widgets.ShortcutBar shortcutBar)
 {
     Widgets.ShortcutButton button = new Widgets.ShortcutButton("showMovesButton");
     button.BackColor = Color.Transparent;
     button.Image = Skins.SkinManager.LoadGuiElement("Game Window/ShortcutBar", "showmoves.png");
     button.HighlightImage = Skins.SkinManager.LoadGuiElement("Game Window/ShortcutBar", "showmoves-h.png");
     button.Click += new EventHandler<SdlDotNet.Widgets.MouseButtonEventArgs>(showMovesButton_Click);
     shortcutBar.AddButton(button);
 }
Example #2
0
 public SportyFontList(Widgets.IWidget widget, string fontName)
 {
     display = XtSports.XtDisplay(widget);
     font = NativeMethods.XLoadQueryFont(XtSports.XtDisplay(widget), fontName);
     if (IntPtr.Zero == font) {
         throw new Exception($"{font}: XLoadQueryFont failed!!");
     }
     fontList = NativeMethods.XmFontListCreate(font, "");
     if (IntPtr.Zero == fontList) {
         throw new Exception($"{font}: XmFontListCreate failed!!");
     }
 }
Example #3
0
        /// <summary>
        /// XmCreateXXの呼び出し
        /// </summary>
        public static IntPtr CallCreate2P(Native.Motif.CreateSymbol sym, Widgets.IWidget parent,string name, Native.Xt.XtArg[] args)
        {
            if (null ==args || 0 == args.Length) {
                return Instance.xmCreateFuncs[(int)sym](parent.NativeHandle.Widget, name, null, 0);
            }

            Native.Xt.NativeXtArg[] au = new Native.Xt.NativeXtArg[args.Length];
            int argc = ExtremeSports.TnkConvertResourceEx(args, au, true);
            foreach(Native.Xt.NativeXtArg k in au) {
                System.Diagnostics.Debug.WriteLine($"NA<A>: {k.Name} : {k.Value}");
            }
            System.Diagnostics.Debug.WriteLine($"XM_CVT {au.Length} -> {argc}");
            IntPtr wgt = Instance.xmCreateFuncs[(int)sym](parent.NativeHandle.Widget, name, au, argc);
            ExtremeSports.TnkFreeDeepCopyArg(au);

            return wgt;
        }
Example #4
0
        public override void Draw(Listing_Standard list)
        {
            var rect = list.GetRect(this.lastHeight);

            var lr = new[] {
                new { Row = this.LeftRow, List = new Listing_Standard(), Rect = rect.LeftPart(this.rate), BGColor = this.leftBackgroundColor },
                new { Row = this.RightRow, List = new Listing_Standard(), Rect = rect.RightPart(1f - this.rate), BGColor = this.rightBackgroundColor }
            }.ToList();

            lr.ForEach(s =>
            {
                if (s.BGColor != Color.clear)
                {
                    Widgets.DrawRectFast(s.Rect, s.BGColor);
                }
                s.List.Begin(s.Rect);
                s.Row.Draw(s.List);
                s.List.End();
            });
            this.lastHeight = lr.Select(s => s.List.CurHeight).Max();

            list.Gap(list.verticalSpacing);
        }
Example #5
0
        private static void DrawPawnAssignments(ResearchProjectDef tech, float height, Vector2 frameOffset, float startPos)
        {
            Vector2 position;
            Vector2 size = new Vector2(height, height);

            using (IEnumerator <Pawn> enumerator = currentPawns.Where(p => HasBeenAssigned(p, tech)).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    position = new Vector2(startPos, frameOffset.y);
                    Rect box      = new Rect(position, size);
                    Rect clickBox = new Rect(position.x + frameOffset.x, position.y, size.x - (2 * frameOffset.x), size.y);
                    Pawn pawn     = enumerator.Current;
                    GUI.DrawTexture(box, PortraitsCache.Get(pawn, size, Rot4.South, cameraZoom: 1.2f));
                    if (Widgets.ButtonInvisible(clickBox))
                    {
                        pawn.TryGetComp <CompKnowledge>().CancelBranch(tech);
                    }
                    TooltipHandler.TipRegion(clickBox, new Func <string>(() => AssignmentStatus(pawn, tech)), tech.GetHashCode());
                    startPos += height / 2;
                }
            }
        }
Example #6
0
        public override void DoWindowContents(Rect inRect)
        {
            Text.Font = GameFont.Small;

            Widgets.Label(new Rect(0, 0, 190, 20), Translator.Translate("ConfirmActionWindow"));

            if (Widgets.ButtonText(new Rect(0, 30, 180, 20), Translator.Translate("ConfirmAction")))
            {
                confirmAction.Invoke();
            }

            if (Widgets.ButtonText(new Rect(0, 60, 180, 20), Translator.Translate("DeclineAction")))
            {
                if (declineAction != null)
                {
                    declineAction.Invoke();
                }
                else
                {
                    Close();
                }
            }
        }
        private void DoBottomButtons(Rect rect)
        {
            Rect rect2 = new Rect(rect.width / 2f - this.BottomButtonSize.x / 2f, rect.height - 55f, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect2, "AcceptButton".Translate(), true, false, true) && this.TrySplitCaravan())
            {
                SoundDefOf.TickHigh.PlayOneShotOnCamera(null);
                this.Close(false);
            }
            Rect rect3 = new Rect(rect2.x - 10f - this.BottomButtonSize.x, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect3, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                this.CalculateAndRecacheTransferables();
            }
            Rect rect4 = new Rect(rect2.xMax + 10f, rect2.y, this.BottomButtonSize.x, this.BottomButtonSize.y);

            if (Widgets.ButtonText(rect4, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
            }
        }
Example #8
0
        /// <summary>
        /// Draw bar with label and overlay text.
        /// </summary>
        /// <param name="rect"> Position to draw. </param>
        /// <param name="fillPercent"> How much the bar is filled. </param>
        /// <param name="fillTex"> Texture for filler. </param>
        /// <param name="label"> Label to prepand to the bar. </param>
        /// <param name="overlayText"> Text to draw over the bar. </param>
        /// <param name="tooltip"> A breakdown of weight carried by pawn. </param>
        public static void BarWithOverlay(Rect rect, float fillPercent, Texture2D fillTex, string label, string overlayText, string tooltip)
        {
            Text.Anchor = TextAnchor.MiddleLeft;

            Rect labelRect = new Rect(rect)
            {
                width = Text.CalcSize(label).x,
            };

            Widgets.Label(labelRect, label);

            rect.xMin += labelRect.width + WidgetRow.DefaultGap;
            Widgets.FillableBar(rect, fillPercent, fillTex, BaseContent.BlackTex, false);

            if (Mouse.IsOver(rect) && !tooltip.NullOrEmpty())
            {
                TooltipHandler.TipRegion(rect, tooltip);
            }

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(rect, overlayText);
            Text.Anchor = TextAnchor.UpperLeft;
        }
        public void BeginScrollView(Rect rect, ref Vector2 scrollPosition, Rect viewRect, GameFont font = GameFont.Small)
        {
            //Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            //rect.height = 100000f;
            //rect.width -= 20f;
            //this.Begin(rect.AtZero());

            //Need BeginGroup before ScrollView, listingRect needs rect.width-=20 but the group doesn't

            GUI.BeginGroup(rect);
            Widgets.BeginScrollView(rect.AtZero(), ref scrollPosition, viewRect, true);

            maxOneColumn = true;

            rect.width -= 20f;
            listingRect = rect;
            ColumnWidth = listingRect.width;

            curX = 0f;
            curY = 0f;

            Text.Font = font;
        }
        public static float DrawHeader(float left, float top, float contentWidth, string labelText, bool drawSeparator = true, TextAnchor alignment = TextAnchor.UpperLeft)
        {
            TextAnchor alignment2 = GUI.skin.label.alignment;
            float      num        = 2f;

            GUI.skin.label.alignment = alignment;
            Rect rect = new Rect(left, top, contentWidth, 22f);

            rect.y    = top;
            Text.Font = GameFont.Small;
            GUI.color = TabDrawer.HeaderColor;
            Widgets.Label(rect, labelText);
            if (drawSeparator)
            {
                GUI.color = TabDrawer.SeparatorColor;
                Widgets.DrawLineHorizontal(left, rect.y + rect.height - num, rect.width);
                GUI.color = TabDrawer.TextColor;
            }
            float num2 = top + (rect.height - num);

            GUI.skin.label.alignment = alignment2;
            return(num2 - top);
        }
Example #11
0
        public static void Settings_SliderLabeled(this Listing_Standard lister, string label, string endSymbol, ref float value, float min, float max, float multiplier = 1f, int decimalPlaces = 2, float hardMaximum = -1f, string valueDisplayWhenMax = "")
        {
            lister.Gap(12f);
            Rect   rect       = lister.GetRect(24f);
            string labelValue = string.Format("{0}" + endSymbol, (Math.Round(value * multiplier, decimalPlaces) * 100));

            if (endSymbol == "%")
            {
                labelValue = string.Format("{0}" + endSymbol, value * 100);
            }
            if (!valueDisplayWhenMax.NullOrEmpty() && hardMaximum > 0) // when value is max, show a string instead (infinite, max, etc)
            {
                if (value >= hardMaximum)
                {
                    labelValue = valueDisplayWhenMax;
                }
            }
            value = Widgets.HorizontalSlider(rect, RoundToNearestHundredth(value), min, max, false, null, label, labelValue);
            if (hardMaximum > 0 && value >= max)
            {
                value = hardMaximum;
            }
        }
Example #12
0
	private bool DoButton(PurposeInfo purposeInfo, Rect rect, float scale = 1.0f)
	{
	  if (!purposeInfo.IsUsed()) return false;

	  Texture icon = purposeInfo.icon;
	  if (icon == null) return false;

	  if (Mouse.IsOver(rect))
		GUI.color = GenUI.MouseoverColor;
	  else
		GUI.color = purposeInfo.color;
	  Verse.Sound.MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
	  //GUI.DrawTexture(rect, Command.BGTex);
	  Widgets.DrawTextureFitted(rect, icon, scale * purposeInfo.scale, purposeInfo.proportions, purposeInfo.texCoords);

	  if (Widgets.ButtonInvisible(rect, false) || Mouse.IsOver(rect) && Input.GetMouseButton(0))
	  {
		clickedPos = purposeInfo.pos;
		return true;
	  }

	  return false;
	}
        public static void DoCopyPasteButtons(Rect rect, Action copyAction, Action pasteAction)
        {
            MouseoverSounds.DoRegion(rect);
            Rect rect2 = new Rect(rect.x, rect.y + (rect.height / 2f - 12f), 18f, 24f);

            if (Widgets.ButtonImage(rect2, TexButton.Copy))
            {
                copyAction();
                SoundDefOf.Tick_High.PlayOneShotOnCamera();
            }
            TooltipHandler.TipRegionByKey(rect2, "Copy");
            if (pasteAction != null)
            {
                Rect rect3 = rect2;
                rect3.x = rect2.xMax;
                if (Widgets.ButtonImage(rect3, TexButton.Paste))
                {
                    pasteAction();
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera();
                }
                TooltipHandler.TipRegionByKey(rect3, "Paste");
            }
        }
        public override void DoWindowContents(Rect inRect)
        {
            float lineHeight = 28f;
            Rect  viewRect   = new Rect(0f, 0f, inRect.width - 20f, lineHeight * this.def.RecordIDs.EnumerableCount());

            Widgets.BeginScrollView(inRect, ref this.scrollPosition, viewRect);
            float num = 0f;

            foreach (RecordIdentifier recordID in this.def.RecordIDs)
            {
                bool flag = ColonistHistoryMod.Settings.ColonistHistoryOutputDetailed[recordID.ID];
                Rect rect = new Rect(0f, num, viewRect.width, lineHeight);
                Widgets.CheckboxLabeled(rect, recordID.def.LabelCap, ref flag);
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlight(rect);
                }
                TooltipHandler.TipRegion(rect, recordID.def.description);
                ColonistHistoryMod.Settings.ColonistHistoryOutputDetailed[recordID.ID] = flag;
                num += lineHeight;
            }
            Widgets.EndScrollView();
        }
Example #15
0
        private void DoAssignFoodRestrictionButtons(Rect rect, Pawn pawn)
        {
            int   num   = Mathf.FloorToInt((rect.width - 4f) * 0.714285731f);
            int   num2  = Mathf.FloorToInt((rect.width - 4f) * 0.2857143f);
            float x     = rect.x;
            Rect  rect2 = new Rect(x, rect.y + 2f, (float)num, rect.height - 4f);
            Rect  rect3 = rect2;
            Func <Pawn, FoodRestriction> getPayload = (Pawn p) => p.foodRestriction.CurrentFoodRestriction;
            Func <Pawn, IEnumerable <Widgets.DropdownMenuElement <FoodRestriction> > > menuGenerator = Button_GenerateMenu;
            string buttonLabel = pawn.foodRestriction.CurrentFoodRestriction.label.Truncate(rect2.width);
            string label       = pawn.foodRestriction.CurrentFoodRestriction.label;

            Widgets.Dropdown(rect3, pawn, getPayload, menuGenerator, buttonLabel, null, label, null, null, paintable: true);
            x += (float)num;
            x += 4f;
            Rect rect4 = new Rect(x, rect.y + 2f, (float)num2, rect.height - 4f);

            if (Widgets.ButtonText(rect4, "AssignTabEdit".Translate()))
            {
                Find.WindowStack.Add(new Dialog_ManageFoodRestrictions(pawn.foodRestriction.CurrentFoodRestriction));
            }
            x += (float)num2;
        }
Example #16
0
        public bool Draw()
        {
            var trueDrawRect = new Rect(this.DrawRect.x + Padding, this.DrawRect.y + Padding, this.DrawRect.width - (Padding * 2f), this.DrawRect.height - (Padding * 2f));

            Widgets.Label(new Rect(trueDrawRect.x, trueDrawRect.y + trueDrawRect.height - this.LabelHeight - 16f, trueDrawRect.width, this.LabelHeight), Label);

            var sliderBox = new Rect(trueDrawRect.x, trueDrawRect.y + trueDrawRect.height - 16f, trueDrawRect.width, trueDrawRect.height - this.LabelHeight);

            GUI.color = Color.white;
            float newValue = GUI.HorizontalSlider(sliderBox, this.CurrentValue, 0f, 1f);

            if (HasChanged(newValue, this.CurrentValue))
            {
                this.CurrentValue = newValue;
                if (this.DoChange != null)
                {
                    DoChange();
                }
                return(true);
            }

            return(false);
        }
Example #17
0
 private void DrawCategoryEntry(KeyBindingCategoryDef category, float width, ref float curY, bool skipDrawing)
 {
     if (!skipDrawing)
     {
         Rect rect = new Rect(0f, curY, width, 40f).ContractedBy(4f);
         Text.Font = GameFont.Medium;
         Widgets.Label(rect, category.LabelCap);
         Text.Font = GameFont.Small;
         if (Mouse.IsOver(rect) && !category.description.NullOrEmpty())
         {
             TooltipHandler.TipRegion(rect, new TipSignal(category.description));
         }
     }
     curY += 40f;
     if (!skipDrawing)
     {
         Color color = GUI.color;
         GUI.color = new Color(0.3f, 0.3f, 0.3f);
         Widgets.DrawLineHorizontal(0f, curY, width);
         GUI.color = color;
     }
     curY += 4f;
 }
Example #18
0
        public void AddWidget(object parameter)
        {
            //
            // create WidgetOperation object to pass
            // open add window
            //
            WidgetOperation widgetOperation = new WidgetOperation()
            {
                Status = WidgetOperation.OperationStatus.CANCEL,
                Widget = new Widget()
            };
            Window addWdigetWindow = new AddWindow(widgetOperation);

            addWdigetWindow.ShowDialog();

            //
            // TODO consider refactoring and use a class with the Widget object and status
            //
            if (widgetOperation.Status != WidgetOperation.OperationStatus.CANCEL)
            {
                Widgets.Add(widgetOperation.Widget);
            }
        }
Example #19
0
 private void DoColumnHeaders(ref float curY)
 {
     if (!compactMode)
     {
         float num = 135f;
         Text.Anchor = TextAnchor.UpperCenter;
         GUI.color   = Widgets.SeparatorLabelColor;
         Widgets.Label(new Rect(num, 3f, 100f, 100f), "Pain".Translate());
         num += 100f;
         List <PawnCapacityDef> list = CapacitiesToDisplay;
         for (int i = 0; i < list.Count; i++)
         {
             Widgets.Label(new Rect(num, 3f, 100f, 100f), list[i].LabelCap.Truncate(100f));
             num += 100f;
         }
         Rect rect = new Rect(num + 8f, 0f, 24f, 24f);
         GUI.DrawTexture(rect, BeCarriedIfSickIcon);
         TooltipHandler.TipRegionByKey(rect, "BeCarriedIfSickTip");
         num        += 40f;
         Text.Anchor = TextAnchor.UpperLeft;
         GUI.color   = Color.white;
     }
 }
Example #20
0
        public override void DefsLoaded()
        {
            Logger.Message("DefsLoaded");
            Settings.GetHandle("str", "String value", "", "value");
            var spinner = Settings.GetHandle("intSpinner", "Spinner", "desc", 5, Validators.IntRangeValidator(0, 30));

            spinner.SpinnerIncrement = 2;
            Settings.GetHandle("enumThing", "Enum setting", "", HandleEnum.DefaultValue, null, "test_enumSetting_");
            Settings.GetHandle("toggle", "Toggle setting extra long title that would not fit into one line", "Toggle setting", false);
            var custom = Settings.GetHandle("custom", "custom setting", "custom setting desc", false);

            custom.CustomDrawerHeight = 30f;
            custom.CustomDrawer       = rect => {
                if (Widgets.ButtonText(new Rect(rect.x, rect.y, rect.width, custom.CustomDrawerHeight), "I Iz Button"))
                {
                    custom.CustomDrawerHeight = custom.CustomDrawerHeight > 30 ? 30f : 400f;
                }
                return(false);
            };
            TestCustomTypeSetting();
            TestGiveShortHash();
            //TestConditionalVisibilitySettings();
        }
        public override void DoWindowContents(Rect inRect)
        {
            Rect titleRect   = inRect.TopPartPixels(40);
            Rect buttonsRect = inRect.BottomPartPixels(40);
            Rect okayRect    = buttonsRect.RightHalf();
            Rect filterRect  = inRect;

            filterRect.height -= 80;
            filterRect.y      += 35;

            Widgets.Label(titleRect, "IW.OutputFilterTitle".Translate());

            ThingFilterUI.DoThingFilterConfigWindow(filterRect, ref scrollPosition, filter,
                                                    openMask: TreeOpenMasks.ThingFilter,
                                                    forceHiddenFilters: specialThingDefs,
                                                    parentFilter: baseFilter);

            if (Widgets.ButtonText(okayRect, "OK".Translate()))
            {
                if (filter.AllowedThingDefs.Count() == 0)
                {
                    extendedBill.ProductAdditionalFilter = null;
                }
                else
                {
                    if (extendedBill.ProductAdditionalFilter == null)
                    {
                        extendedBill.ProductAdditionalFilter = filter;
                    }
                    else
                    {
                        extendedBill.ProductAdditionalFilter.CopyAllowancesFrom(filter);
                    }
                }
                Close();
            }
        }
Example #22
0
            internal void <> m__0()
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                Rect  rect  = this.rect.AtZero();
                float alpha = this.$this.Alpha;

                GUI.color = new Color(1f, 1f, 1f, alpha);
                if (Message.ShouldDrawBackground)
                {
                    GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                    GUI.DrawTexture(rect, BaseContent.WhiteTex);
                    GUI.color = new Color(1f, 1f, 1f, alpha);
                }
                if (CameraJumper.CanJump(this.$this.lookTargets.TryGetPrimaryTarget()))
                {
                    UIHighlighter.HighlightOpportunity(rect, "Messages");
                    Widgets.DrawHighlightIfMouseover(rect);
                }
                Rect rect2 = new Rect(2f, 0f, rect.width - 2f, rect.height);

                Widgets.Label(rect2, this.$this.text);
                if (Current.ProgramState == ProgramState.Playing && CameraJumper.CanJump(this.$this.lookTargets.TryGetPrimaryTarget()))
                {
                    if (Widgets.ButtonInvisible(rect, false))
                    {
                        CameraJumper.TryJumpAndSelect(this.$this.lookTargets.TryGetPrimaryTarget());
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                    }
                }
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
                if (Mouse.IsOver(rect))
                {
                    Messages.Notify_Mouseover(this.$this);
                }
            }
Example #23
0
        public static Rect InlineDoubleMessage(string left, string right, Listing_Standard listing, bool capOff)
        {
            left.Insert(0, " ");
            right.Insert(0, " ");

            var grongo = Text.CalcHeight(left, listing.ColumnWidth / 2);
            var gronk  = Text.CalcHeight(right, listing.ColumnWidth / 2 - 5f);

            var rect = listing.GetRect(Mathf.Max(grongo, gronk));
            var rr   = rect;

            var anchor = Text.Anchor;

            Text.Anchor = TextAnchor.MiddleCenter;

            var leftRect = rect.LeftPart(.5f);

            Widgets.Label(leftRect, left);
            var rightRect = rect.RightPart(.5f);

            rightRect.x += 5;
            Widgets.Label(rightRect, right);

            Text.Anchor = anchor;

            var color = GUI.color;

            GUI.color = color * new Color(1f, 1f, 1f, 0.4f);
            Widgets.DrawLineVertical(rect.center.x, rect.y, rect.height);
            if (capOff)
            {
                Widgets.DrawLineHorizontal(rect.x, rect.y + rect.height, rect.width);
            }
            GUI.color = color;

            return(rr);
        }
        private bool DrawHost( ref Vector2 cur, Rect view, MCMHost host )
		{
			float width = view.width - cur.x - WindowMargin;
			float height = EntryHeight;
			string label = host.Label;

			if( Text.CalcHeight( label, width ) > EntryHeight )
			{
				Text.Font = GameFont.Tiny;
				float height2 = Text.CalcHeight( label, width );
				height = Mathf.Max( height, height2 );
			}

			Text.Anchor = TextAnchor.MiddleLeft;
			Rect labelRect = new Rect( cur.x + WindowMargin, cur.y, width - WindowMargin, height );
			Widgets.Label( labelRect, label );
			Text.Anchor = TextAnchor.UpperLeft;
			Text.Font = GameFont.Small;

			// full viewRect width for overlay and button
			Rect buttonRect = view;
			buttonRect.yMin = cur.y;
			cur.y += height;
			buttonRect.yMax = cur.y;
			GUI.color = Color.grey;
			Widgets.DrawLineHorizontal( view.xMin, cur.y, view.width );
			GUI.color = Color.white;
			if( SelectedHost == host )
			{
				Widgets.DrawHighlightSelected( buttonRect );
			}
			else
			{
				Widgets.DrawHighlightIfMouseover( buttonRect );
			}
			return Widgets.ButtonInvisible( buttonRect );
		}
        public override void DoWindowContents(Rect inRect)
        {
            SetInitialSizeAndPosition();
            Text.Font = GameFont.Small;
            float width = inRect.width / 2f;
            float num1  = 0.0f;
            float num2  = 0.0f;

            for (int index = 0; index < desPanelsCached.Count; ++index)
            {
                Rect rect = new Rect(num1 * width, num2 * 32f, width, 32f);
                ++rect.height;
                if ((double)num1 == 0.0)
                {
                    ++rect.width;
                }

                if (Widgets.ButtonTextSubtle(rect, desPanelsCached[index].def.LabelCap, 0.0f, 24f,
                                             SoundDefOf.MouseoverCategory))
                {
                    this.ClickedCategory(desPanelsCached[index]);
                }
                if (this.selectedDesPanel != desPanelsCached[index])
                {
                    UIHighlighter.HighlightOpportunity(rect, desPanelsCached[index].def.cachedHighlightClosedTag);
                }
                ++num1;
                if ((double)num1 > 1.0)
                {
                    num1 = 0.0f;
                    ++num2;
                }

                GUI.DrawTexture(new Rect(rect.position + new Vector2(4, (32 - 16) / 2), new Vector2(16, 16)),
                                Resources.FindArchitectTabCategoryIcon(desPanelsCached[index].def.defName));
            }
        }
Example #26
0
        private int DrawOutfitSelection(int x, int y)
        {
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("Begin CustomOutfitUI.DrawOutfitSelection " + x + " " + y);
#endif
            if (this.outfitTracker != null && this.outfitTracker.CustomOutfits.Count > 0)
            {
                string label = (this.customOutfit != null) ? this.customOutfit.Label : "Select Outfit";
                if (Widgets.ButtonText(new Rect(x, y, 150, 30), label))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>();
                    foreach (CustomOutfit o in this.outfitTracker.CustomOutfits)
                    {
                        options.Add(new FloatMenuOption(o.Label, delegate
                        {
#if CUSTOM_OUTFIT_UI
                            Log.Warning("Begin CustomOutfitUI.DrawOutfitSelection.Delegate " + o.Label);
#endif
                            if (this.customOutfit != null)
                            {
                                this.outfitTracker.UpdateCustomApparel(this.Dresser);
                            }
                            this.customOutfit = o;
#if CUSTOM_OUTFIT_UI
                            Log.Warning("End CustomOutfitUI.DrawOutfitSelection.Delegate");
#endif
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    Find.WindowStack.Add(new FloatMenu(options));
                }
                return(x + 160);
            }
#if TRACE && CUSTOM_OUTFIT_UI
            Log.Warning("End CustomOutfitUI.DrawOutfitSelection");
#endif
            return(x);
        }
Example #27
0
        public static bool CustomDrawer_Tabs(Rect rect, SettingHandle<String> selected, String[] defaultValues)
        {
            int labelWidth = 140;
            int offset = 0;
            bool change = false;

            foreach (String tab in defaultValues)
            {
                Rect buttonRect = new Rect(rect);
                buttonRect.width = labelWidth;
                buttonRect.position = new Vector2(buttonRect.position.x + offset, buttonRect.position.y);
                Color activeColor = GUI.color;
                bool isSelected = tab == selected.Value;
                if (isSelected)
                    GUI.color = SelectedOptionColor;
                bool clicked = Widgets.ButtonText(buttonRect, tab);
                if (isSelected)
                    GUI.color = activeColor;

                if (clicked)
                {
                    if(selected.Value != tab)
                    {
                        selected.Value = tab;
                    }
                    else
                    {
                        selected.Value = "none";
                    }
                    change = true;
                }

                offset += labelWidth;

            }
            return change;
        }
Example #28
0
            public void Draw(int xOffset, int yOffset)
            {
                Rect rect = this.CalculateRect((float)xOffset, (float)yOffset);

                Find.WindowStack.ImmediateWindow(Gen.HashCombineInt(this.ID, 45574281), rect, WindowLayer.Super, delegate
                {
                    Text.Font   = GameFont.Small;
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Rect rect   = rect.AtZero();
                    float alpha = this.Alpha;
                    GUI.color   = new Color(1f, 1f, 1f, alpha);
                    if (Messages.ShouldDrawMessageBackground)
                    {
                        GUI.color = new Color(0.15f, 0.15f, 0.15f, 0.8f * alpha);
                        GUI.DrawTexture(rect, BaseContent.WhiteTex);
                        GUI.color = new Color(1f, 1f, 1f, alpha);
                    }
                    if (this.lookTarget.IsValid)
                    {
                        UIHighlighter.HighlightOpportunity(rect, "Messages");
                        Widgets.DrawHighlightIfMouseover(rect);
                    }
                    Rect rect2 = new Rect(2f, 0f, rect.width - 2f, rect.height);
                    Widgets.Label(rect2, this.text);
                    if (Current.ProgramState == ProgramState.Playing && this.lookTarget.IsValid && Widgets.ButtonInvisible(rect, false))
                    {
                        CameraJumper.TryJumpAndSelect(this.lookTarget);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ClickingMessages, KnowledgeAmount.Total);
                    }
                    Text.Anchor = TextAnchor.UpperLeft;
                    GUI.color   = Color.white;
                    if (Mouse.IsOver(rect))
                    {
                        Messages.mouseoverMessageIndex = Messages.liveMessages.IndexOf(this);
                    }
                }, false, false, 0f);
            }
Example #29
0
        public void Draw(Rect canvas)
        {
            var statusRect = new Rect(
                canvas.xMax - SmallIconSize - SmallMargin,
                0f,
                SmallIconSize,
                SmallIconSize);

            statusRect = statusRect.CenteredOnYIn(canvas);
            Texture2D icon;

            switch (Met)
            {
            case DependencyStatus.Met:
                icon = Widgets.CheckboxOnTex;
                break;

            case DependencyStatus.WrongVersion:
                Utilities.ActionButton(canvas, () => ResolveWrongVersion(Target, this));
                icon = Widgets.CheckboxOffTex;
                break;

            case DependencyStatus.NotFound:
                Utilities.ActionButton(canvas, () => ResolveFindMod(this, Owner.Button));
                icon = Widgets.CheckboxOffTex;
                break;

            case DependencyStatus.UnknownVersion:
            default:
                Utilities.ActionButton(canvas, () => ResolveFindMod(this, Owner.Button));
                icon = Widgets.CheckboxPartialTex;
                break;
            }
            TooltipHandler.TipRegion(canvas, Tooltip);
            Widgets.Label(canvas, ToString());
            GUI.DrawTexture(statusRect, icon);
        }
Example #30
0
        private static void DrawAreaAllowed(WidgetRow row, Pawn pawn)
        {
            if (pawn.playerSettings == null || !pawn.playerSettings.RespectsAllowedArea)
            {
                return;
            }
            row.Gap(6f);
            bool      flag = pawn.playerSettings != null && pawn.playerSettings.EffectiveAreaRestriction != null;
            Texture2D fillTex;

            if (flag)
            {
                fillTex = pawn.playerSettings.EffectiveAreaRestriction.ColorTexture;
            }
            else
            {
                fillTex = BaseContent.GreyTex;
            }
            Rect rect = row.FillableBar(93f, 16f, 1f, AreaUtility.AreaAllowedLabel(pawn), fillTex, null);

            if (Mouse.IsOver(rect))
            {
                if (flag)
                {
                    pawn.playerSettings.EffectiveAreaRestriction.MarkForDraw();
                }
                Rect rect2 = rect.ContractedBy(-1f);
                Widgets.DrawBox(rect2, 1);
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                AreaUtility.MakeAllowedAreaListFloatMenu(delegate(Area a)
                {
                    pawn.playerSettings.AreaRestriction = a;
                }, true, true, pawn.Map);
            }
        }
Example #31
0
        protected virtual void DoTypeInField(Rect rect)
        {
            GUI.BeginGroup(rect);
            bool  flag = Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return;
            float y    = rect.height - 52f;

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            GUI.SetNextControlName("MapNameField");
            Rect   rect2 = new Rect(5f, y, 400f, 35f);
            string str   = Widgets.TextField(rect2, typingName);

            if (GenText.IsValidFilename(str))
            {
                typingName = str;
            }
            if (!focusedNameArea)
            {
                UI.FocusControl("MapNameField", this);
                focusedNameArea = true;
            }
            Rect rect3 = new Rect(420f, y, rect.width - 400f - 20f, 35f);

            if (Widgets.ButtonText(rect3, "SaveGameButton".Translate()) || flag)
            {
                if (typingName.NullOrEmpty())
                {
                    Messages.Message("NeedAName".Translate(), MessageTypeDefOf.RejectInput, historical: false);
                }
                else
                {
                    DoFileInteraction(typingName);
                }
            }
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
Example #32
0
        private void DrawDirect(Rect inRect)
        {
            ipBuffer = Widgets.TextField(new Rect(inRect.center.x - 200 / 2, 15f, 200, 35f), ipBuffer);

            const float btnWidth = 115f;

            if (Widgets.ButtonText(new Rect(inRect.center.x - btnWidth / 2, 60f, btnWidth, 35f), "MpConnectButton".Translate()))
            {
                string ip = ipBuffer.Trim();

                int      port   = MultiplayerServer.DefaultPort;
                string[] ipport = ip.Split(':');
                if (ipport.Length == 2)
                {
                    int.TryParse(ipport[1], out port);
                }
                else
                {
                    port = MultiplayerServer.DefaultPort;
                }

                if (!IPAddress.TryParse(ipport[0], out IPAddress address))
                {
                    Messages.Message("MpInvalidAddress".Translate(), MessageTypeDefOf.RejectInput, false);
                }
                else
                {
                    Log.Message("Connecting directly");

                    Find.WindowStack.Add(new ConnectingWindow(address, port)
                    {
                        returnToServerBrowser = true
                    });
                    Close(false);
                }
            }
        }
Example #33
0
        public override void DoExtraGuiControls(float leftX, float bottomY)
        {
            ThingDef thingDef = this.PlacingDef as ThingDef;

            if (thingDef != null && thingDef.rotatable)
            {
                Rect winRect = new Rect(leftX, bottomY - 90f, 200f, 90f);
                Find.WindowStack.ImmediateWindow(73095, winRect, WindowLayer.GameUI, delegate
                {
                    RotationDirection rotationDirection = RotationDirection.None;
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Text.Font   = GameFont.Medium;
                    Rect rect   = new Rect(winRect.width / 2f - 64f - 5f, 15f, 64f, 64f);
                    if (Widgets.ButtonImage(rect, TexUI.RotLeftTex))
                    {
                        SoundDefOf.AmountDecrement.PlayOneShotOnCamera(null);
                        rotationDirection = RotationDirection.Counterclockwise;
                        Event.current.Use();
                    }
                    Widgets.Label(rect, KeyBindingDefOf.DesignatorRotateLeft.MainKeyLabel);
                    Rect rect2 = new Rect(winRect.width / 2f + 5f, 15f, 64f, 64f);
                    if (Widgets.ButtonImage(rect2, TexUI.RotRightTex))
                    {
                        SoundDefOf.AmountIncrement.PlayOneShotOnCamera(null);
                        rotationDirection = RotationDirection.Clockwise;
                        Event.current.Use();
                    }
                    Widgets.Label(rect2, KeyBindingDefOf.DesignatorRotateRight.MainKeyLabel);
                    if (rotationDirection != RotationDirection.None)
                    {
                        this.placingRot.Rotate(rotationDirection);
                    }
                    Text.Anchor = TextAnchor.UpperLeft;
                    Text.Font   = GameFont.Small;
                }, true, false, 1f);
            }
        }
Example #34
0
 public static void XtUnmanageChild(Widgets.IWidget wgt)
 {
     NativeMethods.XtUnmanageChild(wgt.NativeHandle.Widget);
 }
Example #35
0
 public RenderTable(Widgets.IWidget widget, string property)
 {
     handle = NativeMethods.XmRenderTableCvtFromProp(widget.NativeHandle.Widget, property, (uint)property.Length);
 }
Example #36
0
 public static IntPtr XtGetGC(Widgets.IWidget w, X11.GCMask value_mask, ref X11.XGCValues values)
 {
     return NativeMethods.XtGetGC(w.NativeHandle.Widget, value_mask, ref values);
 }
Example #37
0
 public Rendition(Widgets.IWidget widget)
 {
     resource = new XResource(null);
     handle = NativeMethods.XmRenditionCreate(widget.NativeHandle.Widget,
                 Native.Motif.StringConstant.XmFONTLIST_DEFAULT_TAG, new Native.Xt.NativeXtArg[]{}, 0);
 }
Example #38
0
 public static void XtUninstallTranslations(Widgets.IWidget wgt)
 {
     NativeMethods.XtUninstallTranslations(wgt.NativeHandle.Widget);
 }
Example #39
0
 public static void XtAddEventHandler(Widgets.IWidget w, ulong event_mask, bool nonmaskable,
              TonNurako.Native.Xt.G.XtEventHandler proc, IntPtr client_data)
 {
     NativeMethods.XtAddEventHandler(w.NativeHandle.Widget, event_mask,nonmaskable,proc,client_data);
 }
Example #40
0
 public Color(Widgets.IWidget widget)
 {
     this.Widget = widget;
 }
Example #41
0
 /// <summary>
 /// コンストラクター
 /// </summary>
 /// <param name="owner">コールバックを追加すべきウイジェット</param>
 public XEventQueue( Widgets.IWidget owner )
 {
     callbacks = new List<QueueData>();
     activeCallbacks = new List<QueueData>();
     target = owner;
 }
Example #42
0
 internal static void XtReleaseGC(Widgets.IWidget w, IntPtr gc)
 {
     NativeMethods.XtReleaseGC(w.NativeHandle.Widget, gc);
 }
Example #43
0
 public static void XtAddCallback(Widgets.IWidget wgt, string type, G.XtCallBack call )
 {
     NativeMethods.XtAddCallback(wgt.NativeHandle.Widget, type, call, IntPtr.Zero);
 }
Example #44
0
 private void OnTxtSearchStringSearch(object o, Widgets.SearchEventArgs args)
 {
     BeginSearch();
 }
Example #45
0
        /// <summary>
        /// バッファーから生成
        /// </summary>
        /// <param name="w">ウイジェット</param>
        /// <param name="buffer">バッファー</param>
        /// <param name="width">幅</param>
        /// <param name="height">高さ</param>
        /// <param name="depth">色深度</param>
        /// <param name="bpp">BPP</param>
        /// <returns>XImageのインスタンス</returns>
        public static XImage FromBuffer(Widgets.IWidget w, byte[] buffer,int width, int height,int depth, int bpp)
        {
            var im = new XImage();
            im.convertBuffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(byte)) * (buffer.Length+1));
            Marshal.Copy(buffer, 0, im.convertBuffer, buffer.Length);

            im.image = NativeMethods.XCreateImage(w.NativeHandle.Display,
                0, (uint)depth, Format.ZPixmap, 0, im.convertBuffer, (uint)width, (uint)height, bpp, 0);
            im.Width = width;
            im.Height = height;
            return im;
        }
 /// <summary>
 /// Adds all buttons to the shortcut bar
 /// </summary>
 /// <param name="shortcutBar">The ShortcutBar to add the buttons to</param>
 public static void AssembleShortcutBarButtons(Widgets.ShortcutBar shortcutBar)
 {
     AddShowMenuButtonToBar(shortcutBar);
     AddShowInvButtonToBar(shortcutBar);
     AddShowMovesButtonToBar(shortcutBar);
     //AddUseRecoveryItemButtonToBar(shortcutBar);
     AddShowOnlineListButtonToBar(shortcutBar);
     AddShowOptionsButtonToBar(shortcutBar);
 }
Example #47
0
        /// <summary>
        /// System.Drawing.Bitmapから生成
        /// </summary>
        /// <param name="w">ウイジェット</param>
        /// <param name="bitmap">bitmap</param>
        /// <returns>XImageのインスタンス</returns>
        public static XImage FromBitmap(Widgets.IWidget w, System.Drawing.Bitmap bitmap)
        {
            var im = new XImage();

            var data = bitmap.LockBits(
                new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                System.Drawing.Imaging.ImageLockMode.ReadWrite,
                System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            int bytes = bitmap.Width * bitmap.Height * 4;
            byte[] buf = new byte[bytes];
            Marshal.Copy(data.Scan0, buf, 0, buf.Length);
            bitmap.UnlockBits(data);

            im.convertBuffer = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(byte)) * (buf.Length+1));
            Marshal.Copy(buf, 0, im.convertBuffer, buf.Length);

            im.image = NativeMethods.XCreateImage(w.NativeHandle.Display,
                0, 24, Format.ZPixmap, 0, im.convertBuffer, (uint)bitmap.Width, (uint)bitmap.Height, 32, 0);

            im.Width = bitmap.Width;
            im.Height = bitmap.Height;

            return im;
        }
Example #48
0
 public Rendition(Widgets.IWidget widget, string tag)
 {
     resource = new XResource(null);
     handle = NativeMethods.XmRenditionCreate(widget.NativeHandle.Widget, tag, new Native.Xt.NativeXtArg[]{}, 0);
 }
Example #49
0
 public static IntPtr XtScreen(Widgets.IWidget wgt)
 {
     return NativeMethods.XtScreen(wgt.NativeHandle.Widget);
 }
Example #50
0
 public static Widgets.IWidget XtNameToWidget(Widgets.IWidget parent, string name)
 {
     var handle = NativeMethods.XtNameToWidget(parent.NativeHandle.Widget, name);
     if (IntPtr.Zero == handle) {
         return null;
     }
     var widget = parent.AppContext.FindWidgetByHandle(handle);
     if (null != widget) {
         return widget;
     }
     return (new Widgets.トンヌラジェット(handle, parent));
 }
Example #51
0
 protected override void Dispose(bool disposing)
 {
     widgets.TextField = null;
     widgets = null;
     base.Dispose(disposing);
 }
Example #52
0
        public bool Create(Widgets.IWidget widget, string tag = Native.Motif.StringConstant.XmFONTLIST_DEFAULT_TAG)
        {
            var args =  Resource.ToXtArg();
            Native.Xt.NativeXtArg[] au = new Native.Xt.NativeXtArg[args.Length];
            int argc = args.Length;
            if (argc != 0) {
                argc = Native.ExtremeSports.TnkConvertResourceEx(args, au, true);
            }
            handle = NativeMethods.XmRenditionCreate(widget.NativeHandle.Widget, tag, au, argc);
            Native.ExtremeSports.TnkFreeDeepCopyArg(au);

            Resource.Clear();
            return true;
        }
Example #53
0
 public static void XtRealizeWidget(Widgets.IWidget wgt)
 {
     NativeMethods.XtRealizeWidget(wgt.NativeHandle.Widget);
 }
Example #54
0
 public SimpleSpinBox()
     : base()
 {
     widgets = new Widgets();
     SimpleSpinBoxEventTable = new TnkXtEvents<Events.SimpleSpinBoxEventArgs>();
 }
Example #55
0
 internal ServerEvent(Widgets.WidgetBase widget)
 {
     ButtonEventTable = new XMaskEventQueue<Events.Server.ButtonEventArgs>();
     MotionEventTable = new XMaskEventQueue<Events.Server.MotionEventArgs>();
     Widget = widget;
 }
Example #56
0
 public static void XtDestroyWidget(Widgets.IWidget wgt)
 {
     NativeMethods.XtDestroyWidget(wgt.NativeHandle.Widget);
 }
Example #57
0
 public static bool XtIsManaged(Widgets.IWidget wgt)
 {
     return (NativeMethods.XtIsManaged(wgt.NativeHandle.Widget).ToInt32() == 0) ? false : true;
 }
Example #58
0
 public static IntPtr XtDisplay(Widgets.IWidget wgt)
 {
     return NativeMethods.XtDisplay(wgt.NativeHandle.Widget);
 }
Example #59
0
 public static IntPtr XtWindow(Widgets.IWidget wgt)
 {
     return NativeMethods.XtWindow(wgt.NativeHandle.Widget);
 }
Example #60
0
 public static void XtAugmentTranslations(Widgets.IWidget wgt, IntPtr translations)
 {
     NativeMethods.XtAugmentTranslations(wgt.NativeHandle.Widget,translations);
 }