Exemple #1
0
        private void DrawVehicleSelect(Rect rect)
        {
            Text.Anchor = TextAnchor.MiddleLeft;

            Rect viewRect = new Rect(0f, rect.yMin, rect.width - ButtonPadding * 2, rect.yMax);

            Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            float num  = scrollPosition.y - 30f;
            float num2 = scrollPosition.y + rect.height;
            float num3 = 30f;

            for (int i = 0; i < availableVehicles.Count; i++)
            {
                VehiclePawn vehicle = availableVehicles[i];

                Rect iconRect = new Rect(5f, num3 + 5f, 30f, 30f);
                Rect rowRect  = new Rect(iconRect.x, iconRect.y, rect.width, 30f);

                if (i % 2 == 1)
                {
                    Widgets.DrawLightHighlight(rowRect);
                }
                rowRect.x = iconRect.width + 10f;

                if (vehicle.VehicleDef.properties.generateThingIcon)
                {
                    Rect    texCoords      = new Rect(0, 0, 1, 1);
                    Vector2 texProportions = vehicle.VehicleDef.graphicData.drawSize;
                    float   x = texProportions.x;
                    texProportions.x = texProportions.y;
                    texProportions.y = x;
                    Widgets.DrawTextureFitted(iconRect, VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East), GenUI.IconDrawScale(vehicle.VehicleDef), texProportions,
                                              texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern));
                }
                else
                {
                    Widgets.ButtonImageFitted(iconRect, VehicleTex.CachedTextureIcons[vehicle.VehicleDef]);
                }

                Widgets.Label(rowRect, vehicle.LabelShortCap);

                bool flag = storedVehicles.Contains(vehicle);

                Vector2 checkposition = new Vector2(rect.width - iconRect.width * 1.5f, rowRect.y + 5f);
                Widgets.Checkbox(checkposition, ref flag);
                if (flag && !storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Add(vehicle);
                }
                else if (!flag && storedVehicles.Contains(vehicle))
                {
                    storedVehicles.Remove(vehicle);
                }

                num3 += rowRect.height;
            }

            Widgets.EndScrollView();
            Text.Anchor = TextAnchor.UpperLeft;
        }
Exemple #2
0
        public override void Draw()
        {
            if (!this.HiddenBehindTerrainNow())
            {
                float averageTileSize = Find.WorldGrid.averageTileSize;
                float transitionPct   = ExpandableWorldObjectsUtility.TransitionPct;

                if (transitionSize < 1)
                {
                    transitionSize += TransitionTakeoff * (int)Find.TickManager.CurTimeSpeed;
                }
                float drawPct = (1 + (transitionPct * Find.WorldCameraDriver.AltitudePercent * ExpandingResize)) * transitionSize;
                if (directionFacing == default)
                {
                    InitializeFacing();
                }
                bool rotateTexture = vehicle.CompVehicleLauncher.Props.faceDirectionOfTravel;
                if (transitionPct <= 0)
                {
                    Vector3    normalized = DrawPos.normalized;
                    Vector3    direction  = Vector3.Cross(normalized, rotateTexture ? directionFacing : Vector3.down);
                    Quaternion quat       = Quaternion.LookRotation(direction, normalized) * Quaternion.Euler(0f, 90f, 0f);
                    Vector3    s          = new Vector3(averageTileSize * 0.7f * drawPct, 1, averageTileSize * 0.7f * drawPct);

                    Matrix4x4 matrix = default;
                    matrix.SetTRS(DrawPos + normalized * TransitionTakeoff, quat, s);
                    int layer = WorldCameraManager.WorldLayer;
                    Graphics.DrawMesh(MeshPool.plane10, matrix, VehicleMat, layer);
                }
                else
                {
                    Rect rect = ExpandableWorldObjectsUtility.ExpandedIconScreenRect(this);
                    if (ExpandingIconFlipHorizontal)
                    {
                        rect.x      = rect.xMax;
                        rect.width *= -1f;
                    }
                    if (Event.current.type != EventType.Repaint)
                    {
                        return;
                    }
                    Matrix4x4 matrix = GUI.matrix;
                    if (rotateTexture)
                    {
                        Verse.UI.RotateAroundPivot(Quaternion.LookRotation(Find.WorldGrid.GetTileCenter(flightPath.First.tile) - position).eulerAngles.y, rect.center);
                    }
                    GenUI.DrawTextureWithMaterial(rect, VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.North), VehicleMatLit);
                    GUI.matrix = matrix;
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Draw extra information on GUI for Transferable <paramref name="trad"/>
        /// </summary>
        /// <param name="trad"></param>
        /// <param name="idRect"></param>
        /// <param name="labelColor"></param>
        public static void DrawVehicleTransferableInfo(Transferable trad, Rect idRect, Color labelColor)
        {
            if (!trad.HasAnyThing && trad.IsThing)
            {
                return;
            }
            if (Mouse.IsOver(idRect))
            {
                Widgets.DrawHighlight(idRect);
            }
            Rect rect = new Rect(0f, 0f, 27f, 27f);

            //Draw Vehicle Icon
            if (trad.AnyThing is VehiclePawn vehicle)
            {
                try
                {
                    Texture2D vehicleIcon    = VehicleTex.VehicleTexture(vehicle.VehicleDef, Rot8.East);
                    Rect      texCoords      = new Rect(0, 0, 1, 1);
                    Vector2   texProportions = vehicle.VehicleDef.graphicData.drawSize;
                    float     x = texProportions.x;
                    texProportions.x = texProportions.y;
                    texProportions.y = x;
                    Widgets.DrawTextureFitted(rect, vehicleIcon, GenUI.IconDrawScale(vehicle.VehicleDef), texProportions,
                                              texCoords, 0, vehicle.VehicleGraphic.MatAt(Rot8.East, vehicle.pattern));
                    if (vehicle.CompCannons is CompCannons comp)
                    {
                        //REDO
                        //foreach (VehicleTurret turret in comp.Cannons)
                        //{
                        //	if (turret.NoGraphic)
                        //	{
                        //		continue;
                        //	}
                        //	Vector2 drawSize = turret.turretDef.graphicData.drawSize;
                        //	//Rect turretRect = new Rect(0, 0, rect.width / drawSize.x,);
                        //	Widgets.DrawTextureFitted(rect, turret.CannonTexture, 1, drawSize, texCoords, Rot8.East.AsAngle + turret.defaultAngleRotated, turret.CannonMaterial);
                        //}
                    }
                }
                catch (Exception ex)
                {
                    Log.ErrorOnce($"Unable to draw {vehicle.Label} for vehicle transferable item. Exception = \"{ex.Message}\"", vehicle.GetHashCode() ^ "TransferableIcon".GetHashCode());
                }
            }

            if (trad.IsThing)
            {
                //Widgets.InfoCardButton(40f, 0f, trad.AnyThing);
            }
            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect2 = new Rect(40f, 0f, idRect.width - 80f, idRect.height);

            Text.WordWrap = false;
            GUI.color     = labelColor;
            Widgets.Label(rect2, trad.LabelCap);
            GUI.color     = Color.white;
            Text.WordWrap = true;
            if (Mouse.IsOver(idRect))
            {
                Transferable localTrad = trad;
                TooltipHandler.TipRegion(idRect, new TipSignal(delegate()
                {
                    if (!localTrad.HasAnyThing && localTrad.IsThing)
                    {
                        return(string.Empty);
                    }
                    string text           = localTrad.LabelCap;
                    string tipDescription = localTrad.TipDescription;
                    if (!tipDescription.NullOrEmpty())
                    {
                        text = text + ": " + tipDescription;
                    }
                    return(text);
                }, localTrad.GetHashCode()));
            }
        }