예제 #1
0
 public void Draw(Tex2D texture, Vec2 position, Rectangle?sourceRectangle, Color color) => this.Draw(texture, position, sourceRectangle, color, 0.0f, Vec2.Zero, 1f, SpriteEffects.None, 0.0f);
예제 #2
0
 public MaterialAlbum()
 {
     this._effect       = Content.Load <MTEffect>("Shaders/album");
     this._albumTexture = Content.Load <Tex2D>("playBookPageOffset");
 }
예제 #3
0
        internal void DoDrawInternalTex2D(
            Tex2D texture,
            Vec4 destinationRectangle,
            Rectangle?sourceRectangle,
            Color color,
            float rotation,
            Vec2 origin,
            SpriteEffects effect,
            float depth,
            bool autoFlush,
            Material fx)
        {
            ++DuckGame.Graphics.currentDrawIndex;
            MTSpriteBatchItem batchItem = this._batcher.CreateBatchItem();

            batchItem.Depth    = depth;
            batchItem.Texture  = texture.nativeObject as Texture2D;
            batchItem.Material = fx;
            if (sourceRectangle.HasValue)
            {
                this._tempRect = sourceRectangle.Value;
            }
            else
            {
                this._tempRect.x      = 0.0f;
                this._tempRect.y      = 0.0f;
                this._tempRect.width  = (float)texture.width;
                this._tempRect.height = (float)texture.height;
            }
            this._texCoordTL.x = (float)((double)this._tempRect.x / (double)texture.width + 9.99999974737875E-06);
            this._texCoordTL.y = (float)((double)this._tempRect.y / (double)texture.height + 9.99999974737875E-06);
            this._texCoordBR.x = (float)(((double)this._tempRect.x + (double)this._tempRect.width) / (double)texture.width - 9.99999974737875E-06);
            this._texCoordBR.y = (float)(((double)this._tempRect.y + (double)this._tempRect.height) / (double)texture.height - 9.99999974737875E-06);
            if ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None)
            {
                float y = this._texCoordBR.y;
                this._texCoordBR.y = this._texCoordTL.y;
                this._texCoordTL.y = y;
            }
            if ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None)
            {
                float x = this._texCoordBR.x;
                this._texCoordBR.x = this._texCoordTL.x;
                this._texCoordTL.x = x;
            }
            batchItem.Set(destinationRectangle.x, destinationRectangle.y, -origin.x, -origin.y, destinationRectangle.z, destinationRectangle.w, (float)Math.Sin((double)rotation), (float)Math.Cos((double)rotation), color, this._texCoordTL, this._texCoordBR);
            if (Recorder.currentRecording != null)
            {
                if (DuckGame.Graphics.recordMetadata)
                {
                    batchItem.MetaData          = new MTSpriteBatchItemMetaData();
                    batchItem.MetaData.texture  = texture;
                    batchItem.MetaData.rotation = rotation;
                    batchItem.MetaData.color    = color;
                    batchItem.MetaData.tempRect = this._tempRect;
                    batchItem.MetaData.effect   = effect;
                    batchItem.MetaData.depth    = depth;
                }
                Recorder.currentRecording.LogDraw(texture.textureIndex, new Vec2(batchItem.vertexTL.Position.X, batchItem.vertexTL.Position.Y), new Vec2(batchItem.vertexBR.Position.X, batchItem.vertexBR.Position.Y), rotation, color, (short)this._tempRect.x, (short)this._tempRect.y, (short)((double)this._tempRect.width * ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None ? -1.0 : 1.0)), (short)((double)this._tempRect.height * ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None ? -1.0 : 1.0)), depth, texture.currentObjectIndex, DuckGame.Graphics.currentObjectIndex, DuckGame.Graphics.currentDrawIndex);
            }
            if (Recorder.globalRecording != null)
            {
                Recorder.globalRecording.LogDraw(texture.textureIndex, new Vec2(batchItem.vertexTL.Position.X, batchItem.vertexTL.Position.Y), new Vec2(batchItem.vertexBR.Position.X, batchItem.vertexBR.Position.Y), rotation, color, (short)this._tempRect.x, (short)this._tempRect.y, (short)((double)this._tempRect.width * ((effect & SpriteEffects.FlipHorizontally) != SpriteEffects.None ? -1.0 : 1.0)), (short)((double)this._tempRect.height * ((effect & SpriteEffects.FlipVertically) != SpriteEffects.None ? -1.0 : 1.0)), depth, texture.currentObjectIndex, DuckGame.Graphics.currentObjectIndex, DuckGame.Graphics.currentDrawIndex);
            }
            if (!autoFlush)
            {
                return;
            }
            this.FlushIfNeeded();
        }
 public MaterialGold(Thing t)
 {
     this._effect      = Content.Load <MTEffect>("Shaders/gold");
     this._goldTexture = Content.Load <Tex2D>("bigGold");
     this._thing       = t;
 }
예제 #5
0
        public static ReskinFile tryLoadReskin(Tex2D texture, bool loadHat = true)
        {
            try{ return(ReskinFile.ParseFile(TextureHelper.getBitmap(texture), loadHat)); } catch { }

            return(null);
        }
예제 #6
0
        public override void Draw()
        {
            if (this.open)
            {
                this.scrollBarTop              = (int)((double)this._box.y - (double)this._box.halfHeight + 1.0 + 16.0);
                this.scrollBarBottom           = (int)((double)this._box.y + (double)this._box.halfHeight - 1.0 - 16.0);
                this.scrollBarScrollableHeight = this.scrollBarBottom - this.scrollBarTop;
                if (this.fixView)
                {
                    Layer.HUD.camera.width  *= 2f;
                    Layer.HUD.camera.height *= 2f;
                    this.fixView             = false;
                }
                DuckGame.Graphics.DrawRect(new Vec2(this._box.x - this._box.halfWidth, this._box.y - this._box.halfHeight), new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0 - 2.0), this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f));
                DuckGame.Graphics.DrawRect(new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0), this._box.y - this._box.halfHeight), new Vec2(this._box.x + this._box.halfWidth, this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f));
                Rectangle r = this.ScrollBarBox();
                DuckGame.Graphics.DrawRect(r, this._draggingScrollbar || r.Contains(Mouse.position) ? Color.LightGray : Color.Gray, new Depth(0.5f));
                for (int index1 = 0; index1 < this._maxModsToShow; ++index1)
                {
                    int index2 = this._scrollItemOffset + index1;
                    if (index2 < this._mods.Count)
                    {
                        float x = this._box.x - this._box.halfWidth;
                        float y = this._box.y - this._box.halfHeight + (float)(36 * index1);
                        if (this._transferItem == null && this._hoverIndex == index2)
                        {
                            DuckGame.Graphics.DrawRect(new Vec2(x, y), new Vec2((float)((double)x + (double)this._box.width - 14.0), y + 36f), Color.White * 0.6f, new Depth(0.4f));
                        }
                        else if ((index2 & 1) != 0)
                        {
                            DuckGame.Graphics.DrawRect(new Vec2(x, y), new Vec2((float)((double)x + (double)this._box.width - 14.0), y + 36f), Color.White * 0.1f, new Depth(0.4f));
                        }
                        Mod mod = this._mods[index2];
                        if (mod != null)
                        {
                            Tex2D previewTexture = mod.previewTexture;
                            if (this._noImage.texture != previewTexture)
                            {
                                this._noImage.texture = previewTexture;
                                this._noImage.scale   = new Vec2(32f / (float)previewTexture.width);
                            }
                            DuckGame.Graphics.DrawRect(new Vec2(x + 2f, y + 2f), new Vec2((float)((double)x + 36.0 - 2.0), (float)((double)y + 36.0 - 2.0)), Color.Gray, new Depth(0.5f), false, 2f);
                            DuckGame.Graphics.Draw(this._noImage, x + 2f, y + 2f, new Depth(0.5f));
                            string str = "#" + (object)(index2 + 1) + ": ";
                            string text;
                            if (!mod.configuration.loaded)
                            {
                                text = str + mod.configuration.name;
                            }
                            else
                            {
                                text = str + mod.configuration.displayName + "|WHITE| v" + mod.configuration.version.ToString() + " by |PURPLE|" + mod.configuration.author;
                            }
                            this._fancyFont.Draw(text, new Vec2((float)((double)x + 36.0 + 10.0), y + 2f), Color.Yellow, new Depth(0.5f));
                            DuckGame.Graphics.Draw(!mod.configuration.isWorkshop ? (Sprite)this._localIcon : this._steamIcon, x + 36f, y + 2.5f, new Depth(0.5f));
                            if (!mod.configuration.loaded)
                            {
                                if (mod.configuration.disabled)
                                {
                                    this._fancyFont.Draw("Mod is disabled.", new Vec2(x + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.LightGray, new Depth(0.5f));
                                }
                                else
                                {
                                    this._fancyFont.Draw("|DGGREEN|Mod will be enabled on next restart.", new Vec2(x + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.Orange, new Depth(0.5f));
                                }
                            }
                            else if (mod.configuration.disabled)
                            {
                                this._fancyFont.Draw("|DGRED|Mod will be disabled on next restart.", new Vec2(x + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.Orange, new Depth(0.5f));
                            }
                            else
                            {
                                this._fancyFont.Draw(mod.configuration.description, new Vec2(x + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.White, new Depth(0.5f));
                            }
                        }
                        else
                        {
                            DuckGame.Graphics.Draw((Sprite)this._newIcon, x + 2f, y + 1f, new Depth(0.5f));
                            this._fancyFont.scale = new Vec2(1.5f);
                            this._fancyFont.Draw("Get " + (this._mods.Count == 1 ? "some" : "more") + " mods!", new Vec2(x + 36f, y + 11f), Color.White, new Depth(0.5f));
                            this._fancyFont.scale = new Vec2(1f);
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (this._awaitingChanges)
                {
                    DuckGame.Graphics.DrawString("Restart required for some changes to take effect!", new Vec2((float)((double)this.x - (double)this.halfWidth + 128.0), (float)((double)this.y - (double)this.halfHeight + 8.0)), Color.Red, new Depth(0.6f));
                }
                if (this._transferItem != null)
                {
                    DuckGame.Graphics.DrawRect(new Rectangle(this._box.x - this._box.halfWidth, this._box.y - this._box.halfHeight, this._box.width, this._box.height), Color.Black * 0.9f, new Depth(0.7f));
                    string text = "Creating item...";
                    if (this._transferring)
                    {
                        TransferProgress uploadProgress = this._transferItem.GetUploadProgress();
                        string           str;
                        switch (uploadProgress.status)
                        {
                        case ItemUpdateStatus.PreparingConfig:
                            str = "Preparing config";
                            break;

                        case ItemUpdateStatus.PreparingContent:
                            str = "Preparing content";
                            break;

                        case ItemUpdateStatus.UploadingContent:
                            str = "Uploading content";
                            break;

                        case ItemUpdateStatus.UploadingPreviewFile:
                            str = "Uploading preview";
                            break;

                        case ItemUpdateStatus.CommittingChanges:
                            str = "Committing changes";
                            break;

                        default:
                            str = "Waiting";
                            break;
                        }
                        if (uploadProgress.bytesTotal != 0UL)
                        {
                            float amount = (float)uploadProgress.bytesDownloaded / (float)uploadProgress.bytesTotal;
                            str = str + " (" + (object)(int)((double)amount * 100.0) + "%)";
                            DuckGame.Graphics.DrawRect(new Rectangle((float)((double)this._box.x - (double)this._box.halfWidth + 8.0), this._box.y - 8f, this._box.width - 16f, 16f), Color.LightGray, new Depth(0.8f));
                            DuckGame.Graphics.DrawRect(new Rectangle((float)((double)this._box.x - (double)this._box.halfWidth + 8.0), this._box.y - 8f, Lerp.FloatSmooth(0.0f, this._box.width - 16f, amount), 16f), Color.Green, new Depth(0.8f));
                        }
                        text = str + "...";
                    }
                    else if (this._needsUpdateNotes)
                    {
                        DuckGame.Graphics.DrawRect(new Rectangle(this._updateTextBox.position.x - 1f, this._updateTextBox.position.y - 1f, this._updateTextBox.size.x + 2f, this._updateTextBox.size.y + 2f), Color.Gray, new Depth(0.85f), false);
                        DuckGame.Graphics.DrawRect(new Rectangle(this._updateTextBox.position.x, this._updateTextBox.position.y, this._updateTextBox.size.x, this._updateTextBox.size.y), Color.Black, new Depth(0.85f));
                        this._updateTextBox.Draw();
                        text = "Enter change notes:";
                        DuckGame.Graphics.DrawString(this._updateButtonText, new Vec2(this._updateButton.x, this._updateButton.y), this._updateButton.Contains(Mouse.position) ? Color.Yellow : Color.White, new Depth(0.9f), scale: 2f);
                    }
                    float stringWidth = DuckGame.Graphics.GetStringWidth(text, scale: 2f);
                    DuckGame.Graphics.DrawString(text, new Vec2(this._box.x - stringWidth / 2f, (float)((double)this._box.y - (double)this._box.halfHeight + 24.0)), Color.White, new Depth(0.8f), scale: 2f);
                }
                if (Mouse.available && !this._gamepadMode)
                {
                    this._cursor.depth    = new Depth(1f);
                    this._cursor.scale    = new Vec2(1f, 1f);
                    this._cursor.position = Mouse.position;
                    this._cursor.frame    = 0;
                    if (Editor.hoverTextBox)
                    {
                        this._cursor.frame       = 5;
                        this._cursor.position.y -= 4f;
                        this._cursor.scale       = new Vec2(0.5f, 1f);
                    }
                    this._cursor.Draw();
                }
            }
            base.Draw();
        }
예제 #7
0
 public override void Update()
 {
     if (this._pressWait > 0)
     {
         --this._pressWait;
     }
     if (this._editModMenu.open)
     {
         if (!UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             this._editModMenu.Close();
             this.Open();
             return;
         }
     }
     else if (this.open)
     {
         if (this._transferItem != null && !this._needsUpdateNotes)
         {
             if (!this._transferring)
             {
                 if (this._transferItem.result == SteamResult.OK)
                 {
                     WorkshopItemData dat = new WorkshopItemData();
                     if (this._selectedMod.configuration.workshopID == 0UL)
                     {
                         this._selectedMod.configuration.SetWorkshopID(this._transferItem.id);
                         dat.name        = this._selectedMod.configuration.displayName;
                         dat.description = this._selectedMod.configuration.description;
                         dat.visibility  = RemoteStoragePublishedFileVisibility.Private;
                         dat.tags        = new List <string>();
                         dat.tags.Add("Mod");
                     }
                     else
                     {
                         dat.changeNotes = this._updateTextBox.text;
                     }
                     string pathString = this._selectedMod.configuration.directory + "/content/";
                     DuckFile.CreatePath(pathString);
                     string path1 = pathString + "screenshot.png";
                     if (!File.Exists(path1))
                     {
                         File.Delete(path1);
                         Tex2D  screenshot = this._selectedMod.screenshot;
                         Stream stream     = (Stream)DuckFile.Create(path1);
                         ((Texture2D)screenshot.nativeObject).SaveAsPng(stream, screenshot.width, screenshot.height);
                         stream.Dispose();
                     }
                     dat.previewPath = path1;
                     string str = DuckFile.workshopDirectory + (object)this._transferItem.id + "/content";
                     if (Directory.Exists(str))
                     {
                         Directory.Delete(str, true);
                     }
                     DuckFile.CreatePath(str);
                     UIModManagement.DirectoryCopy(this._selectedMod.configuration.directory, str + "/" + this._selectedMod.configuration.name, true);
                     if (Directory.Exists(str + this._selectedMod.configuration.name + "/build"))
                     {
                         Directory.Delete(str + this._selectedMod.configuration.name + "/build", true);
                     }
                     if (Directory.Exists(str + this._selectedMod.configuration.name + "/.vs"))
                     {
                         Directory.Delete(str + this._selectedMod.configuration.name + "/.vs", true);
                     }
                     if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll"))
                     {
                         string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.dll";
                         File.SetAttributes(path2, FileAttributes.Normal);
                         File.Delete(path2);
                     }
                     if (File.Exists(str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash"))
                     {
                         string path2 = str + this._selectedMod.configuration.name + "/" + this._selectedMod.configuration.name + "_compiled.hash";
                         File.SetAttributes(path2, FileAttributes.Normal);
                         File.Delete(path2);
                     }
                     dat.contentFolder = str;
                     this._transferItem.ApplyWorkshopData(dat);
                     if (this._transferItem.needsLegal)
                     {
                         Steam.ShowWorkshopLegalAgreement("312530");
                     }
                     this._transferring = true;
                     this._transferItem.ResetProcessing();
                 }
             }
             else if (this._transferItem.finishedProcessing)
             {
                 Steam.OverlayOpenURL("http://steamcommunity.com/sharedfiles/filedetails/?id=" + (object)this._transferItem.id);
                 Directory.Delete(DuckFile.workshopDirectory + (object)this._transferItem.id + "/", true);
                 this._transferItem.ResetProcessing();
                 this._transferItem = (WorkshopItem)null;
                 this._transferring = false;
             }
             base.Update();
             return;
         }
         if (this._gamepadMode)
         {
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
         }
         else
         {
             this._hoverIndex = -1;
             for (int index = 0; index < this._maxModsToShow && this._scrollItemOffset + index < this._mods.Count; ++index)
             {
                 if (new Rectangle((float)(int)(this._box.x - this._box.halfWidth), (float)(int)(this._box.y - this._box.halfHeight + (float)(36 * index)), (float)((int)this._box.width - 14), 36f).Contains(Mouse.position))
                 {
                     this._hoverIndex = this._scrollItemOffset + index;
                     break;
                 }
             }
         }
         if (this._transferItem != null)
         {
             if (this._updateTextBox != null)
             {
                 Editor.hoverTextBox           = false;
                 this._updateTextBox.position  = new Vec2((float)((double)this._box.x - (double)this._box.halfWidth + 16.0), (float)((double)this._box.y - (double)this._box.halfHeight + 48.0));
                 this._updateTextBox.size      = new Vec2(this._box.width - 32f, this._box.height - 80f);
                 this._updateTextBox._maxLines = (int)((double)this._updateTextBox.size.y / (double)this._fancyFont.characterHeight);
                 this._updateTextBox.Update();
                 float stringWidth = DuckGame.Graphics.GetStringWidth(this._updateButtonText, scale: 2f);
                 float height      = DuckGame.Graphics.GetStringHeight(this._updateButtonText) * 2f;
                 this._updateButton = new Rectangle(this._box.x - stringWidth / 2f, (float)((double)this._box.y + (double)this._box.halfHeight - 24.0), stringWidth, height);
                 if (this._updateButton.Contains(Mouse.position) && Mouse.left == InputState.Pressed)
                 {
                     this._needsUpdateNotes = false;
                     this._updateTextBox.LoseFocus();
                 }
                 else if (Keyboard.Pressed(Keys.Escape))
                 {
                     this._needsUpdateNotes = false;
                     this._transferItem     = (WorkshopItem)null;
                     this._updateTextBox.LoseFocus();
                     new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate();
                     return;
                 }
             }
         }
         else if (this._hoverIndex != -1)
         {
             this._selectedMod = this._mods[this._hoverIndex];
             if (Input.Pressed("SHOOT"))
             {
                 if (this._selectedMod != null && this._selectedMod.configuration != null)
                 {
                     if (this._selectedMod.configuration.disabled)
                     {
                         this._selectedMod.configuration.Enable();
                     }
                     else
                     {
                         this._selectedMod.configuration.Disable();
                     }
                     this.modsChanged = true;
                     SFX.Play("rockHitGround", 0.8f);
                 }
             }
             else if (Input.Pressed("SELECT") && this._pressWait == 0 && this._gamepadMode || !this._gamepadMode && Mouse.left == InputState.Pressed)
             {
                 if (this._selectedMod != null)
                 {
                     this._editModMenu.title = this._selectedMod.configuration.loaded ? "|YELLOW|" + this._selectedMod.configuration.displayName : "|YELLOW|" + this._selectedMod.configuration.name;
                     this._editModMenu.Remove((UIComponent)this._deleteOrUnsubItem);
                     this._editModMenu.Remove((UIComponent)this._uploadItem);
                     this._editModMenu.Remove((UIComponent)this._visitItem);
                     if (!this._selectedMod.configuration.isWorkshop && this._selectedMod.configuration.loaded)
                     {
                         this._uploadItem.text = this._selectedMod.configuration.workshopID == 0UL ? "UPLOAD" : "UPDATE";
                         this._editModMenu.Insert((UIComponent)this._uploadItem, 1, true);
                     }
                     if (!this._selectedMod.configuration.isWorkshop && !this._selectedMod.configuration.loaded)
                     {
                         this._deleteOrUnsubItem.text = "DELETE";
                         this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true);
                     }
                     else if (this._selectedMod.configuration.isWorkshop)
                     {
                         this._deleteOrUnsubItem.text = "UNSUBSCRIBE";
                         this._editModMenu.Insert((UIComponent)this._deleteOrUnsubItem, 1, true);
                     }
                     if (this._selectedMod.configuration.isWorkshop)
                     {
                         this._editModMenu.Insert((UIComponent)this._visitItem, 1, true);
                     }
                     this._disableOrEnableItem.text = this._selectedMod.configuration.disabled ? "ENABLE" : "DISABLE";
                     this._editModMenu.dirty        = true;
                     SFX.Play("rockHitGround", 0.8f);
                     new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._editModMenu).Activate();
                     return;
                 }
                 Steam.OverlayOpenURL("http://steamcommunity.com/workshop/browse/?appid=312530&searchtext=&childpublishedfileid=0&browsesort=trend&section=readytouseitems&requiredtags%5B%5D=Mod");
             }
         }
         else
         {
             this._selectedMod = (Mod)null;
         }
         if (this._gamepadMode)
         {
             this._draggingScrollbar = false;
             if (Input.Pressed("DOWN"))
             {
                 ++this._hoverIndex;
             }
             else if (Input.Pressed("UP"))
             {
                 --this._hoverIndex;
             }
             if (Input.Pressed("STRAFE"))
             {
                 this._hoverIndex -= 10;
             }
             else if (Input.Pressed("RAGDOLL"))
             {
                 this._hoverIndex += 10;
             }
             if (this._hoverIndex < 0)
             {
                 this._hoverIndex = 0;
             }
             if ((double)(this._oldPos - Mouse.positionScreen).lengthSq > 200.0)
             {
                 this._gamepadMode = false;
             }
         }
         else
         {
             if (!this._draggingScrollbar)
             {
                 if (Mouse.left == InputState.Pressed && this.ScrollBarBox().Contains(Mouse.position))
                 {
                     this._draggingScrollbar = true;
                     this._oldPos            = Mouse.position;
                 }
                 if ((double)Mouse.scroll > 0.0)
                 {
                     this._scrollItemOffset += 5;
                     this._hoverIndex       += 5;
                 }
                 else if ((double)Mouse.scroll < 0.0)
                 {
                     this._scrollItemOffset -= 5;
                     this._hoverIndex       -= 5;
                     if (this._hoverIndex < 0)
                     {
                         this._hoverIndex = 0;
                     }
                 }
             }
             else if (Mouse.left != InputState.Down)
             {
                 this._draggingScrollbar = false;
             }
             else
             {
                 Vec2 vec2 = Mouse.position - this._oldPos;
                 this._oldPos          = Mouse.position;
                 this.scrollBarOffset += (int)vec2.y;
                 if (this.scrollBarOffset > this.scrollBarScrollableHeight)
                 {
                     this.scrollBarOffset = this.scrollBarScrollableHeight;
                 }
                 else if (this.scrollBarOffset < 0)
                 {
                     this.scrollBarOffset = 0;
                 }
                 this._scrollItemOffset = (int)((double)(this._mods.Count - this._maxModsToShow) * (double)((float)this.scrollBarOffset / (float)this.scrollBarScrollableHeight));
             }
             if (Input.Pressed("ANY"))
             {
                 this._gamepadMode = true;
                 this._oldPos      = Mouse.positionScreen;
             }
         }
         if (this._scrollItemOffset < 0)
         {
             this._scrollItemOffset = 0;
         }
         else if (this._scrollItemOffset > Math.Max(0, this._mods.Count - this._maxModsToShow))
         {
             this._scrollItemOffset = Math.Max(0, this._mods.Count - this._maxModsToShow);
         }
         if (this._hoverIndex >= this._mods.Count)
         {
             this._hoverIndex = this._mods.Count - 1;
         }
         else if (this._hoverIndex >= this._scrollItemOffset + this._maxModsToShow)
         {
             this._scrollItemOffset += this._hoverIndex - (this._scrollItemOffset + this._maxModsToShow) + 1;
         }
         else if (this._hoverIndex >= 0 && this._hoverIndex < this._scrollItemOffset)
         {
             this._scrollItemOffset -= this._scrollItemOffset - this._hoverIndex;
         }
         this.scrollBarOffset = this._scrollItemOffset == 0 ? 0 : (int)Lerp.FloatSmooth(0.0f, (float)this.scrollBarScrollableHeight, (float)this._scrollItemOffset / (float)(this._mods.Count - this._maxModsToShow));
         if (!Editor.hoverTextBox && !UIMenu.globalUILock && (Input.Pressed("QUACK") || Keyboard.Pressed(Keys.Escape)))
         {
             if (this.modsChanged)
             {
                 this.Close();
                 MonoMain.pauseMenu = DuckNetwork.OpenModsRestartWindow(this._openOnClose);
             }
             else
             {
                 new UIMenuActionOpenMenu((UIComponent)this, (UIComponent)this._openOnClose).Activate();
             }
             this.modsChanged = false;
             return;
         }
     }
     if (this._showingMenu)
     {
         HUD.CloseAllCorners();
         this._showingMenu = false;
     }
     base.Update();
 }
예제 #8
0
 public MaterialRedHot(Thing t)
 {
     this._effect      = Content.Load <MTEffect>("Shaders/redhot");
     this._goldTexture = Content.Load <Tex2D>("redHot");
     this._thing       = t;
 }
예제 #9
0
        public override void Draw()
        {
            if (this._downloadModsMenu.open)
            {
                this._downloadModsMenu.DoDraw();
            }
            if (this.open)
            {
                this.scrollBarTop              = (int)((double)this._box.y - (double)this._box.halfHeight + 1.0 + 16.0);
                this.scrollBarBottom           = (int)((double)this._box.y + (double)this._box.halfHeight - 1.0 - 16.0);
                this.scrollBarScrollableHeight = this.scrollBarBottom - this.scrollBarTop;
                if (this.fixView)
                {
                    Layer.HUD.camera.width  *= 2f;
                    Layer.HUD.camera.height *= 2f;
                    this.fixView             = false;
                }
                DuckGame.Graphics.DrawRect(new Vec2(this._box.x - this._box.halfWidth, this._box.y - this._box.halfHeight), new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0 - 2.0), this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f));
                DuckGame.Graphics.DrawRect(new Vec2((float)((double)this._box.x + (double)this._box.halfWidth - 12.0), this._box.y - this._box.halfHeight), new Vec2(this._box.x + this._box.halfWidth, this._box.y + this._box.halfHeight), Color.Black, new Depth(0.4f));
                Rectangle r = this.ScrollBarBox();
                DuckGame.Graphics.DrawRect(r, this._draggingScrollbar || r.Contains(Mouse.position) ? Color.LightGray : Color.Gray, new Depth(0.5f));
                if (this._lobbies.Count == 0)
                {
                    this._fancyFont.Draw("No games found!", new Vec2(this._box.x - this._box.halfWidth + 10f, (float)((double)this._box.y - (double)this._box.halfHeight + 0.0) + 2f), Color.Yellow, new Depth(0.5f));
                }
                this._lobbies = this._lobbies.OrderByDescending <UIServerBrowser.LobbyData, bool>((Func <UIServerBrowser.LobbyData, bool>)(x => x.canJoin)).ToList <UIServerBrowser.LobbyData>();
                for (int index1 = 0; index1 < this._maxLobbiesToShow; ++index1)
                {
                    int index2 = this._scrollItemOffset + index1;
                    if (index2 < this._lobbies.Count)
                    {
                        float x1 = this._box.x - this._box.halfWidth;
                        float y  = this._box.y - this._box.halfHeight + (float)(36 * index1);
                        if (this._hoverIndex == index2)
                        {
                            DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.White * 0.6f, new Depth(0.4f));
                        }
                        else if ((index2 & 1) != 0)
                        {
                            DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.White * 0.1f, new Depth(0.4f));
                        }
                        UIServerBrowser.LobbyData lobby = this._lobbies[index2];
                        if (lobby != null)
                        {
                            this._noImage.texture = this.defaultImage;
                            this._noImage.scale   = new Vec2(1f, 1f);
                            List <Tex2D> tex2DList = new List <Tex2D>();
                            string       name      = lobby.name;
                            string       text1     = "|WHITE||GRAY|\n";
                            if (lobby.workshopItems.Count > 0)
                            {
                                WorkshopItem workshopItem1 = lobby.workshopItems[0];
                                if (workshopItem1.data != null)
                                {
                                    lobby.workshopItems = lobby.workshopItems.OrderByDescending <WorkshopItem, int>((Func <WorkshopItem, int>)(x => x.data == null ? 0 : x.data.votesUp)).ToList <WorkshopItem>();
                                    if (!lobby.downloadedWorkshopItems)
                                    {
                                        lobby.hasFirstMod   = true;
                                        lobby.hasRestOfMods = true;
                                        bool flag = true;
                                        foreach (WorkshopItem workshopItem2 in lobby.workshopItems)
                                        {
                                            ulong id = workshopItem2.id;
                                            if (ModLoader.accessibleMods.FirstOrDefault <Mod>((Func <Mod, bool>)(x => (long)x.configuration.workshopID == (long)id)) == null)
                                            {
                                                if (flag)
                                                {
                                                    lobby.hasFirstMod = false;
                                                }
                                                else
                                                {
                                                    lobby.hasRestOfMods = false;
                                                }
                                            }
                                            flag = false;
                                        }
                                        lobby.downloadedWorkshopItems = true;
                                    }
                                    string str1 = !lobby.hasFirstMod ? "|RED|Requires " + workshopItem1.name : "|DGGREEN|Requires " + workshopItem1.name;
                                    string str2 = lobby.hasRestOfMods ? "|DGGREEN|" : "|RED|";
                                    if (lobby.workshopItems.Count == 2)
                                    {
                                        str1 = str1 + str2 + " +" + (lobby.workshopItems.Count - 1).ToString() + " other mod.";
                                    }
                                    else if (lobby.workshopItems.Count > 2)
                                    {
                                        str1 = str1 + str2 + " +" + (lobby.workshopItems.Count - 1).ToString() + " other mods.";
                                    }
                                    text1 = str1 + "\n|GRAY|";
                                    if (!UIServerBrowser._previewMap.ContainsKey(workshopItem1.id))
                                    {
                                        if (workshopItem1.data.previewPath != null)
                                        {
                                            if (workshopItem1.data.previewPath != "")
                                            {
                                                try
                                                {
                                                    WebClient webClient = new WebClient();
                                                    string    str3      = this.PreviewPathForWorkshopItem(workshopItem1.id);
                                                    DuckFile.CreatePath(str3);
                                                    if (System.IO.File.Exists(str3))
                                                    {
                                                        DuckFile.Delete(str3);
                                                    }
                                                    webClient.DownloadFileAsync(new Uri(workshopItem1.data.previewPath), str3);
                                                    webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.Completed);
                                                    UIServerBrowser._clientMap[(object)webClient] = workshopItem1.id;
                                                }
                                                catch (Exception ex)
                                                {
                                                }
                                            }
                                        }
                                        UIServerBrowser._previewMap[workshopItem1.id] = (Tex2D)null;
                                    }
                                    else
                                    {
                                        Tex2D preview = UIServerBrowser._previewMap[workshopItem1.id];
                                        if (preview != null)
                                        {
                                            tex2DList.Add(preview);
                                        }
                                    }
                                }
                            }
                            if (lobby.wallMode == "1")
                            {
                                text1 += "Wall Mode. ";
                            }
                            if (lobby.requiredWins != "")
                            {
                                text1 = text1 + "First to " + lobby.requiredWins.ToString() + " ";
                            }
                            if (lobby.restsEvery != "")
                            {
                                text1 = text1 + "rests every " + lobby.restsEvery.ToString() + ". ";
                            }
                            if (lobby.customLevels != "" && lobby.customLevels != "0")
                            {
                                text1 = text1 + lobby.customLevels.ToString() + " Custom Levels. ";
                            }
                            DuckGame.Graphics.DrawRect(new Vec2(x1 + 2f, y + 2f), new Vec2((float)((double)x1 + 36.0 - 2.0), (float)((double)y + 36.0 - 2.0)), Color.Gray, new Depth(0.5f), false, 2f);
                            if (tex2DList.Count > 0)
                            {
                                Vec2 zero = Vec2.Zero;
                                for (int index3 = 0; index3 < 4; ++index3)
                                {
                                    if (index3 < tex2DList.Count)
                                    {
                                        this._noImage.texture = tex2DList[index3];
                                        if (tex2DList.Count > 1)
                                        {
                                            this._noImage.scale = new Vec2(16f / (float)this._noImage.texture.width);
                                        }
                                        else
                                        {
                                            this._noImage.scale = new Vec2(32f / (float)this._noImage.texture.width);
                                        }
                                        if (this._noImage.texture.width != this._noImage.texture.height)
                                        {
                                            if (this._noImage.texture.width > this._noImage.texture.height)
                                            {
                                                this._noImage.scale = new Vec2(32f / (float)this._noImage.texture.height);
                                                DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Rectangle((float)(this._noImage.texture.width / 2 - this._noImage.texture.height / 2), 0.0f, (float)this._noImage.texture.height, (float)this._noImage.texture.height), new Depth(0.5f));
                                            }
                                            else
                                            {
                                                DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Rectangle(0.0f, 0.0f, (float)this._noImage.texture.width, (float)this._noImage.texture.width), new Depth(0.5f));
                                            }
                                        }
                                        else
                                        {
                                            DuckGame.Graphics.Draw(this._noImage, x1 + 2f + zero.x, y + 2f + zero.y, new Depth(0.5f));
                                        }
                                        zero.x += 16f;
                                        if ((double)zero.x >= 32.0)
                                        {
                                            zero.x  = 0.0f;
                                            zero.y += 16f;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                DuckGame.Graphics.Draw(this._noImage, x1 + 2f, y + 2f, new Depth(0.5f));
                            }
                            string text2 = name;
                            if (lobby.maxPlayers != "")
                            {
                                text2 = text2 + " (" + lobby.lobby.users.Count.ToString() + "/" + lobby.numSlots.ToString() + ")";
                            }
                            if (!lobby.canJoin)
                            {
                                string str = text2 + " |DGRED|(";
                                if (lobby.version != DG.version)
                                {
                                    switch (DuckNetwork.CheckVersion(lobby.version))
                                    {
                                    case NMVersionMismatch.Type.Older:
                                        str += "They have an older version.";
                                        break;

                                    case NMVersionMismatch.Type.Newer:
                                        str += "They have a newer version.";
                                        break;

                                    default:
                                        str += "They have a different version.";
                                        break;
                                    }
                                }
                                else if (lobby.started == "true")
                                {
                                    str += "This game is in progress.";
                                }
                                else if (lobby.numSlots != "" && lobby.lobby.users.Count >= Convert.ToInt32(lobby.numSlots))
                                {
                                    str += "Lobby is full.";
                                }
                                else if (lobby.type != "2")
                                {
                                    str += "This game is not public.";
                                }
                                else if (lobby.hasLocalMods)
                                {
                                    str += "This game is using non-workshop mods.";
                                }
                                text2 = str + ")";
                                DuckGame.Graphics.DrawRect(new Vec2(x1, y), new Vec2((float)((double)x1 + (double)this._box.width - 14.0), y + 36f), Color.Black * 0.5f, new Depth(0.99f));
                            }
                            this._fancyFont.maxWidth = 1000;
                            this._fancyFont.Draw(text2, new Vec2((float)((double)x1 + 36.0 + 10.0), y + 2f), Color.Yellow, new Depth(0.5f));
                            if (lobby.version == DG.version)
                            {
                                this._fancyFont.Draw(lobby.version, new Vec2((float)((double)x1 + 430.0 + 10.0), y + 2f), Colors.DGGreen * 0.35f, new Depth(0.5f));
                            }
                            else
                            {
                                this._fancyFont.Draw(lobby.version, new Vec2((float)((double)x1 + 430.0 + 10.0), y + 2f), Colors.DGRed * 0.35f, new Depth(0.5f));
                            }
                            DuckGame.Graphics.Draw(this._steamIcon, x1 + 36f, y + 2.5f, new Depth(0.5f));
                            this._fancyFont.Draw(text1, new Vec2(x1 + 36f, y + 6f + (float)this._fancyFont.characterHeight), Color.LightGray, new Depth(0.5f));
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                if (Mouse.available && !this._gamepadMode)
                {
                    this._cursor.depth    = new Depth(1f);
                    this._cursor.scale    = new Vec2(1f, 1f);
                    this._cursor.position = Mouse.position;
                    this._cursor.frame    = 0;
                    if (Editor.hoverTextBox)
                    {
                        this._cursor.frame       = 5;
                        this._cursor.position.y -= 4f;
                        this._cursor.scale       = new Vec2(0.5f, 1f);
                    }
                    this._cursor.Draw();
                }
            }
            base.Draw();
        }
예제 #10
0
 public void SetCapeTexture(Texture2D tex)
 {
     this._capeTexture = (Tex2D)tex;
     this.maxLength    = this._capeTexture.height / 2 - 6;
 }