Esempio n. 1
0
        private void ResizeManager_MouseMove(object sender, MouseEventArgs e)
        {
            if (IsMouseDown)
            {
                Label resizer = (Label)sender;
                int   index   = (int)resizer.Tag;

                if (index <= 2) // Top row
                {
                    tempRect.Y      += e.Y - my;
                    tempRect.Height -= e.Y - my;
                }
                else if (index >= 4 && index <= 6) // Bottom row
                {
                    tempRect.Height += e.Y - my;
                }

                if (index >= 2 && index <= 4) // Right row
                {
                    tempRect.Width += e.X - mx;
                }
                else if (index >= 6 || index == 0) // Left row
                {
                    tempRect.X     += e.X - mx;
                    tempRect.Width -= e.X - mx;
                }

                region.CurrentArea.Rectangle = GraphicsMgr.FixRectangle(tempRect);
                Update(tempRect);
            }
        }
        /// <summary>
        /// Remove the corners of a window by replacing the background of these corners by transparency.
        /// </summary>
        /// <param name="handle"></param>
        /// <param name="windowImage"></param>
        /// <param name="redBGImage"></param>
        /// <param name="windowRect"></param>
        /// <returns></returns>
        private static Image RemoveCorners(IntPtr handle, Image windowImage, Bitmap redBGImage, Rectangle windowRect)
        {
            const int cornerSize = 5;

            if (windowRect.Width > cornerSize * 2 && windowRect.Height > cornerSize * 2)
            {
                FileSystem.AppendDebug("Clean transparent corners");

                if (redBGImage == null)
                {
                    using (Form form = new Form())
                    {
                        form.FormBorderStyle = FormBorderStyle.None;
                        form.ShowInTaskbar   = false;
                        form.BackColor       = Color.Red;

                        NativeMethods.ShowWindow(form.Handle, (int)NativeMethods.WindowShowStyle.ShowNormalNoActivate);
                        NativeMethods.SetWindowPos(form.Handle, handle, windowRect.X, windowRect.Y, windowRect.Width, windowRect.Height, NativeMethods.SWP_NOACTIVATE);
                        Application.DoEvents();
                        redBGImage = CaptureRectangle(windowRect) as Bitmap;
                    }
                }

                return(GraphicsMgr.RemoveCorners(windowImage, redBGImage));
            }
            return(null);
        }
Esempio n. 3
0
        private void InitializeComponent()
        {
            this.SuspendLayout();
            this.Bounds           = GraphicsMgr.GetScreenBounds();
            this.CausesValidation = false;
            this.ControlBox       = true;
            this.Cursor           = Cursors.Cross;
            this.DoubleBuffered   = true;
            this.FormBorderStyle  = FormBorderStyle.None;
            this.KeyPreview       = true;
            this.MaximizeBox      = false;
            this.MinimizeBox      = false;
            this.Name             = "Crop";
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.ShowIcon = false;
#if !DEBUG
            this.TopMost = true;
#endif
            this.ShowInTaskbar = false;
            this.ResumeLayout(false);

            this.KeyDown += new KeyEventHandler(Crop2_KeyDown);

            this.DoubleClick += new EventHandler(Crop_MouseDobuleClick);
        }
Esempio n. 4
0
        /// <summary>
        /// Executes Draw events.
        /// </summary>
        internal static void CallDrawEvents()
        {
            foreach (var scene in Scenes)
            {
                if (scene.Visible)
                {
                    CurrentScene = scene;
                    foreach (var layer in scene.Layers)
                    {
                        if (
                            layer.Visible &&
                            !layer.IsGUI &&
                            !GraphicsMgr.CurrentCamera.Filter(scene.Name, layer.Name)
                            )
                        {
                            CurrentLayer = layer;

                            bool hasPostprocessing = (
                                GraphicsMgr.CurrentCamera.PostprocessingMode == PostprocessingMode.CameraAndLayers &&
                                layer.PostprocessorEffects.Count > 0
                                );

                            if (hasPostprocessing)
                            {
                                GraphicsMgr.SetSurfaceTarget(GraphicsMgr.CurrentCamera._postprocessorLayerBuffer, GraphicsMgr.CurrentView);
                                GraphicsMgr.Device.Clear(Color.TransparentBlack);
                            }

                            foreach (var entity in layer._depthSortedEntities)
                            {
                                if (entity.Visible && !entity.Destroyed)
                                {
                                    foreach (var componentPair in entity._components)
                                    {
                                        if (componentPair.Value.Visible)
                                        {
                                            SystemMgr.Draw(componentPair.Value);
                                        }
                                    }
                                    entity.Draw();
                                }
                            }

                            if (hasPostprocessing)
                            {
                                GraphicsMgr.ResetSurfaceTarget();

                                var oldRasterizer = GraphicsMgr.Rasterizer;
                                GraphicsMgr.Rasterizer = GraphicsMgr._cameraRasterizerState;
                                GraphicsMgr.SetTransformMatrix(Matrix.CreateTranslation(Vector3.Zero));
                                layer.ApplyPostprocessing();
                                GraphicsMgr.ResetTransformMatrix();
                                GraphicsMgr.Rasterizer = oldRasterizer;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GraphicsMgr.Init(GraphicsDevice);

            new SpriteGroupResourceBox("DefaultSprites", "Graphics/Default");
            new DirectoryResourceBox <Effect>("Effects", "Effects");
            new DirectoryResourceBox <TiledMap>("Maps", "Maps");
            new Fonts();
        }
Esempio n. 6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GraphicsMgr.Init(GraphicsDevice);

            new Resources.Sprites.Default();
            new Fonts();
            new Maps();
            new Effects();
        }
 public void init(int width, int height, GraphicsMgr graphics)
 {
     this.gfx       = graphics;
     this.mapWidth  = width;
     this.mapHeight = height;
     this.maskMap   = new byte[width, height];
     this.clearMap();
     this.buildings.Clear();
 }
Esempio n. 8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            GraphicsMgr.Init(GraphicsDevice);

            Resources.Sprites.Default.Load();
            Fonts.Load();
            Effects.Load();
            Maps.Load();
        }
Esempio n. 9
0
        public Light(Vector2f Pos, float Range, Color Clr)
        {
            this.Range = Range;

            LSprite        = new Sprite(GraphicsMgr.GetTexture("lightmask.png"));
            Position       = Pos;
            LSprite.Origin = new Vector2f(LSprite.Texture.Size.X, LSprite.Texture.Size.Y) / 2;
            LSprite.Scale  = new Vector2f(Range / LSprite.Texture.Size.X, Range / LSprite.Texture.Size.Y);
            LSprite.Color  = Clr;
        }
Esempio n. 10
0
        public static Image CaptureScreen(bool showCursor)
        {
            Image img = CaptureRectangle(GraphicsMgr.GetScreenBounds());

            if (showCursor)
            {
                DrawCursor(img);
            }
            return(img);
        }
        /// <summary>
        /// Captures a screenshot of a window using Windows GDI
        /// </summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <returns>the captured window image</returns>
        public static Image CaptureWithGDI(IntPtr handle)
        {
            FileSystem.AppendDebug("Capturing with GDI");
            Rectangle windowRect;

            if (Engine.conf.ActiveWindowTryCaptureChildren)
            {
                windowRect = new WindowRectangle(handle).CalculateWindowRectangle();
            }
            else
            {
                windowRect = NativeMethods.GetWindowRectangle(handle);
            }

            windowRect = NativeMethods.MaximizedWindowFix(handle, windowRect);

            FileSystem.AppendDebug("Window rectangle: " + windowRect.ToString());

            Image windowImage = null;

            if (Engine.conf.ActiveWindowClearBackground)
            {
                windowImage = CaptureWindowWithTransparencyGDI(handle, windowRect);
            }

            if (windowImage == null)
            {
                using (new Freeze(handle))
                {
                    windowImage = CaptureRectangle(windowRect);
                }

                if (Engine.conf.ActiveWindowCleanTransparentCorners)
                {
                    Image result = RemoveCorners(handle, windowImage, null, windowRect);
                    if (result != null)
                    {
                        windowImage = result;
                    }
                }

                if (Engine.conf.ActiveWindowIncludeShadows)
                {
                    // Draw shadow manually to be able to have shadows in every case
                    windowImage = GraphicsMgr.AddBorderShadow((Bitmap)windowImage, true);
                }

                if (Engine.conf.ShowCursor)
                {
                    DrawCursor(windowImage, windowRect.Location);
                }
            }

            return(windowImage);
        }
Esempio n. 12
0
 public void Draw()
 {
     GraphicsMgr.AddTransformMatrix(
         // Origin point for the panel is on the bottom, so we need to center it.
         Matrix.CreateTranslation((Vector2.UnitY * Root.Size.Y / 2f).ToVector3())
         * Matrix.CreateRotationZ(MathHelper.ToRadians(Rotation))
         * Matrix.CreateTranslation(Position.ToVector3())
         );
     Root.Draw();
     GraphicsMgr.ResetTransformMatrix();
 }
        /// <summary>
        /// Captures a screenshot of a window using the Windows DWM
        /// </summary>
        /// <param name="handle">handle of the window to capture</param>
        /// <returns>the captured window image</returns>
        public static Image CaptureWithDWM(IntPtr handle)
        {
            FileSystem.AppendDebug("Capturing with DWM");
            Image  windowImage = null;
            Bitmap redBGImage  = null;

            Rectangle windowRect = NativeMethods.GetWindowRectangle(handle);

            windowRect = NativeMethods.MaximizedWindowFix(handle, windowRect);

            if (Engine.HasAero && Engine.conf.ActiveWindowClearBackground)
            {
                windowImage = CaptureWindowWithTransparencyDWM(handle, windowRect, out redBGImage, Engine.conf.ActiveWindowCleanTransparentCorners);
            }

            if (windowImage == null)
            {
                FileSystem.AppendDebug("Standard capture (no transparency)");
                windowImage = CaptureRectangle(windowRect);
            }

            if (Engine.conf.ActiveWindowCleanTransparentCorners)
            {
                Image result = RemoveCorners(handle, windowImage, redBGImage, windowRect);
                if (result != null)
                {
                    windowImage = result;
                }
            }

            if (windowImage != null)
            {
                if (Engine.conf.ActiveWindowIncludeShadows)
                {
                    // Draw shadow manually to be able to have shadows in every case
                    windowImage = GraphicsMgr.AddBorderShadow((Bitmap)windowImage, true);
                    Point shadowOffset = GraphicsMgr.ShadowOffset;
                    windowRect.X -= shadowOffset.X;
                    windowRect.Y -= shadowOffset.Y;
                }

                if (Engine.conf.ActiveWindowShowCheckers)
                {
                    windowImage = ImageEffects.DrawCheckers(windowImage);
                }

                if (Engine.conf.ShowCursor)
                {
                    DrawCursor(windowImage, windowRect.Location);
                }
            }

            return(windowImage);
        }
 public static void UpdateNotifyIconProgress(NotifyIcon ni, int progress)
 {
     if (ni != null)
     {
         using (Bitmap img = (Bitmap)GraphicsMgr.DrawProgressIcon(UploadManager.GetAverageProgress()))
         {
             IntPtr hicon = img.GetHicon();
             ni.Icon = Icon.FromHandle(hicon);
             NativeMethods.DestroyIcon(hicon);
         }
     }
 }
Esempio n. 15
0
        public override void Draw()
        {
            var canvasSize = GameMgr.WindowManager.CanvasSize;

            Text.CurrentFont = Resources.Fonts.Arial;
            Text.HorAlign    = TextAlign.Left;
            Text.VerAlign    = TextAlign.Top;

            // Description.
            if (CurrentFactory.Description != "")
            {
                var padding  = 8;
                var textSize = Text.CurrentFont.MeasureString(CurrentFactory.Description);
                var origin   = Vector2.UnitX * (canvasSize - (textSize + Vector2.One * padding * 2));
                GraphicsMgr.CurrentColor = _barColor;
                RectangleShape.Draw(origin, origin + textSize + Vector2.One * padding * 2, false);
                GraphicsMgr.CurrentColor = _textColor;
                Text.Draw(CurrentFactory.Description, Vector2.One * padding + origin);
            }
            // Description.


            // Bottom bar.
            GraphicsMgr.AddTransformMatrix(Matrix.CreateTranslation(new Vector3(0, canvasSize.Y - _barHeight, 0)));

            GraphicsMgr.CurrentColor = _barColor;
            RectangleShape.Draw(Vector2.Zero, canvasSize, false);

            GraphicsMgr.CurrentColor = _textColor;
            Text.Draw(
                "fps: " + GameMgr.Fps
                + " | Current scene: " + CurrentScene.Name
                + Environment.NewLine
                + _prevSceneButton + "/" + _nextSceneButton + " - change scene, "
                + _restartButton + " - restart current scene, "
                + _toggleUIButton + " - toggle UI, "
                + _toggleFullscreenButton + " - toggle fullscreen"

                + Environment.NewLine
                + CameraController.UpButton + "/"
                + CameraController.DownButton + "/"
                + CameraController.LeftButton + "/"
                + CameraController.RightButton + " - move camera, "
                + CameraController.ZoomInButton + "/" + CameraController.ZoomOutButton + " - zoom, "
                + CameraController.RotateLeftButton + "/" + CameraController.RotateRightButton + " - rotate"
                ,
                _indent
                );

            GraphicsMgr.ResetTransformMatrix();
            // Bottom bar.
        }
Esempio n. 16
0
        /// <summary>
        /// Creates a new surface and draws test stuff on it.
        /// </summary>
        void InitSurface()
        {
            _surface = new Surface(128, 128);

            GraphicsMgr.SetSurfaceTarget(_surface);

            GraphicsMgr.Device.Clear(_secondaryColor);

            GraphicsMgr.CurrentColor = _mainColor;
            CircleShape.Draw(new Vector2(64, 64), 64, false);

            GraphicsMgr.ResetSurfaceTarget();
        }
        public static Image ApplySizeChanges(Image img)
        {
            switch (Engine.conf.ImageSizeType)
            {
            case ImageSizeType.FIXED:
                img = GraphicsMgr.ChangeImageSize(img, Engine.conf.ImageSizeFixedWidth, Engine.conf.ImageSizeFixedHeight);
                break;

            case ImageSizeType.RATIO:
                img = GraphicsMgr.ChangeImageSize(img, Engine.conf.ImageSizeRatioPercentage);
                break;
            }
            return(img);
        }
 public void initStorageBuilding(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.buildingType == 2)
     {
         this.updateStockpile(gfx, vm);
     }
     if (this.buildingType == 3)
     {
         this.updateGranary(gfx, vm);
     }
     if (this.buildingType == 0x23)
     {
         this.updateInn(gfx, vm);
     }
 }
Esempio n. 19
0
        public void showGood(GraphicsMgr gfx, int cellID, int buildingType, int level)
        {
            if ((buildingType < 0) || (level == 0))
            {
                this.cell[cellID].Visible = false;
            }
            else
            {
                this.cell[cellID].Visible = true;
                float posX     = this.cell[cellID].PosX;
                float posY     = this.cell[cellID].PosY;
                int   spriteNo = level - 1;
                switch (buildingType)
                {
                case 13:
                    spriteNo += 80;
                    break;

                case 14:
                    spriteNo += 0x80;
                    break;

                case 15:
                    spriteNo += 160;
                    break;

                case 0x10:
                    spriteNo += 0x70;
                    break;

                case 0x11:
                    spriteNo += 0x60;
                    break;

                case 0x12:
                    spriteNo += 0x40;
                    break;
                }
                this.cell[cellID].Initialize(gfx, GFXLibrary.Instance.Goods2TexID, spriteNo);
                PointF tf = new PointF(32f, 101f);
                this.cell[cellID].Center = tf;
                this.cell[cellID].PosX   = posX;
                this.cell[cellID].PosY   = posY;
            }
        }
        public void showGood(GraphicsMgr gfx, int cellID, int buildingType, int level)
        {
            if ((buildingType < 0) || (level == 0))
            {
                this.cell[cellID].Visible = false;
            }
            else
            {
                this.cell[cellID].Visible = true;
                float posX = this.cell[cellID].PosX;
                float posY = this.cell[cellID].PosY;
                int spriteNo = level - 1;
                switch (buildingType)
                {
                    case 13:
                        spriteNo += 80;
                        break;

                    case 14:
                        spriteNo += 0x80;
                        break;

                    case 15:
                        spriteNo += 160;
                        break;

                    case 0x10:
                        spriteNo += 0x70;
                        break;

                    case 0x11:
                        spriteNo += 0x60;
                        break;

                    case 0x12:
                        spriteNo += 0x40;
                        break;
                }
                this.cell[cellID].Initialize(gfx, GFXLibrary.Instance.Goods2TexID, spriteNo);
                PointF tf = new PointF(32f, 101f);
                this.cell[cellID].Center = tf;
                this.cell[cellID].PosX = posX;
                this.cell[cellID].PosY = posY;
            }
        }
Esempio n. 21
0
        public void Draw()
        {
            // Transform matrices took care of the rotations,
            // so all panels assume they are drawn with no rotation\offset.
            RectangleShape.DrawBySize(Offset - Vector2.UnitY * Size / 2f, Size, true);

            CircleShape.Draw(Offset, 4, true);

            LineShape.Draw(Offset, Offset - Vector2.UnitY * 8);

            if (Attachments == null)
            {
                return;
            }

            // Transform matrices stack.
            GraphicsMgr.AddTransformMatrix(
                Matrix.CreateTranslation(-(Vector2.UnitY * Size / 2f).ToVector3())
                );
            foreach (var panel in Attachments)
            {
                // We need to offset the child panel by half of parent's
                // width or height depending on the side.
                var length     = Size.X / 2f;
                var resultSide = panel.Side;
                if (panel.Side % 2 == 0)
                {
                    length = Size.Y / 2f;
                }

                GraphicsMgr.AddTransformMatrix(
                    //Matrix.CreateRotationZ(0.3f) // Future reference - use this to pivot the panels.
                    Matrix.CreateTranslation(-(Vector2.UnitY * length).ToVector3())
                    * Matrix.CreateRotationZ((float)(Math.PI - Math.PI / 2f * resultSide))
                    * Matrix.CreateTranslation(Offset.ToVector3())
                    );
                panel.Draw();
                GraphicsMgr.ResetTransformMatrix();
            }

            GraphicsMgr.ResetTransformMatrix();
        }
 public void showGood(GraphicsMgr gfx, int cellID, int buildingType, int level)
 {
     if ((buildingType < 0) || (level == 0))
     {
         this.cell[cellID].Visible = false;
     }
     else
     {
         this.cell[cellID].Visible = true;
         float posX     = this.cell[cellID].PosX;
         float posY     = this.cell[cellID].PosY;
         int   spriteNo = level - 1;
         spriteNo += 0xc0;
         this.cell[cellID].Initialize(gfx, GFXLibrary.Instance.Goods1TexID, spriteNo);
         PointF tf = new PointF(32f, 101f);
         this.cell[cellID].Center = tf;
         this.cell[cellID].PosX   = posX;
         this.cell[cellID].PosY   = posY;
     }
 }
Esempio n. 23
0
        public override void Draw()
        {
            GraphicsMgr.AddTransformMatrix(
                Matrix.CreateTranslation((GraphicsMgr.CurrentCamera.Position - GraphicsMgr.CurrentCamera.Size / 2).ToVector3())
                );

            GraphicsMgr.CurrentColor = Color.White;

            _sun.Draw(_sunBasePosition, _sun.Origin);

            _mountains.Draw(
                _mountainsBasePosition + GraphicsMgr.CurrentCamera.Size * Vector2.UnitY,
                _mountains.Origin
                );


            DrawParallaxForest(_forest1, _forest1Parallax);
            DrawParallaxForest(_forest2, _forest2Parallax);

            GraphicsMgr.ResetTransformMatrix();
        }
Esempio n. 24
0
        private void Crop_MouseMove(object sender, MouseEventArgs e)
        {
            IsAreaIntersect();

            if (IsMoving)
            {
                Rectangle rect = CurrentArea.Rectangle;
                rect.X               += e.X - positionOnClick.X;
                rect.Y               += e.Y - positionOnClick.Y;
                positionOnClick       = e.Location;
                CurrentArea.Rectangle = rect;
                Resize.Update();
            }

            if (IsMouseDown && CurrentArea != null && !CurrentArea.Selected)
            {
                currentPosition = GetMousePosition();
                Rectangle rect = new Rectangle(positionOnClick.X, positionOnClick.Y, currentPosition.X - positionOnClick.X, currentPosition.Y - positionOnClick.Y);
                CurrentArea.Rectangle = GraphicsMgr.FixRectangle(rect);
            }
        }
Esempio n. 25
0
        protected override void init()
        {
            if (false || GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height < 800 || GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width < 1400)
            {
                GraphicsMgr.PreferredBackBufferWidth  = 1280;
                GraphicsMgr.PreferredBackBufferHeight = 720;
            }
            else
            {
                GraphicsMgr.PreferredBackBufferWidth  = 1920;
                GraphicsMgr.PreferredBackBufferHeight = 1080;
            }

            GraphicsMgr.GraphicsProfile = GraphicsProfile.HiDef;
            //GraphicsMgr.PreferMultiSampling = true;
            //GraphicsMgr.GraphicsDevice.RasterizerState = new RasterizerState { MultiSampleAntiAlias = true };

            //Fab5_Game.inst().GraphicsDevice.SamplerStates[0].MipFilter = TextureFilter.Anisotropic;

            //Fab5_Game.inst().GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;



            //GraphicsMgr.SynchronizeWithVerticalRetrace = false;
            //IsFixedTimeStep = false;



            GraphicsMgr.ApplyChanges();
            //
            GraphicsMgr.ToggleFullScreen();
            Microsoft.Xna.Framework.Media.MediaPlayer.Volume = 0.7f;

            var form = (System.Windows.Forms.Form)System.Windows.Forms.Control.FromHandle(this.Window.Handle);

            form.Location = new System.Drawing.Point(300, 200);

            enter_state(new Splash_Screen_State());
        }
        public void showGood(GraphicsMgr gfx, int cellID, int buildingType, int level)
        {
            if ((buildingType < 0) || (level == 0))
            {
                this.cell[cellID].Visible = false;
            }
            else
            {
                this.cell[cellID].Visible = true;
                float posX = this.cell[cellID].PosX;
                float posY = this.cell[cellID].PosY;
                int spriteNo = level - 1;
                switch (buildingType)
                {
                    case 6:
                        spriteNo += 0x90;
                        break;

                    case 7:
                        spriteNo += 0xe0;
                        break;

                    case 8:
                        spriteNo += 0x30;
                        break;

                    case 9:
                        spriteNo += 0xd0;
                        break;
                }
                this.cell[cellID].Initialize(gfx, GFXLibrary.Instance.Goods1TexID, spriteNo);
                PointF tf = new PointF(32f, 101f);
                this.cell[cellID].Center = tf;
                this.cell[cellID].PosX = posX;
                this.cell[cellID].PosY = posY;
            }
        }
        private static Image DrawImageWatermark(Image img, string imgPath)
        {
            try
            {
                if (!string.IsNullOrEmpty(imgPath) && File.Exists(imgPath))
                {
                    int   offset = (int)Engine.conf.WatermarkOffset;
                    Image img2   = Image.FromFile(imgPath);
                    img2 = GraphicsMgr.ChangeImageSize((Bitmap)img2, (float)Engine.conf.WatermarkImageScale);
                    Point imgPos = FindPosition(Engine.conf.WatermarkPositionMode, offset, img.Size, img2.Size, 0);
                    if (Engine.conf.WatermarkAutoHide && ((img.Width < img2.Width + offset) ||
                                                          (img.Height < img2.Height + offset)))
                    {
                        return(img);
                        //throw new Exception("Image size smaller than watermark size.");
                    }

                    Graphics g = Graphics.FromImage(img);
                    g.SmoothingMode = SmoothingMode.HighQuality;
                    g.DrawImage(img2, imgPos);
                    if (Engine.conf.WatermarkAddReflection)
                    {
                        Bitmap bmp = AddReflection((Bitmap)img2, 50, 200);
                        g.DrawImage(bmp, new Rectangle(imgPos.X, imgPos.Y + img2.Height - 1, bmp.Width, bmp.Height));
                    }
                    if (Engine.conf.WatermarkUseBorder)
                    {
                        g.DrawRectangle(new Pen(Color.Black), new Rectangle(imgPos.X, imgPos.Y, img2.Width - 1, img2.Height - 1));
                    }
                }
            }
            catch (Exception ex)
            {
                FileSystem.AppendDebug("Error while drwaing image watermark", ex);
            }
            return(img);
        }
Esempio n. 28
0
        private static void Main(string[] args)
        {
            #if DEBUG
            AllocConsole();
            #endif
            try
            {
                args = new string[] { "-InstallerVersion", CurrentInstallerBuild.ToString(), "en" };
            #if DEBUG
                Console.WriteLine("Nichosy " + DataExport.version);
            #endif

                DataExport.Fill();
                bool flag = false;
                bool flag2 = false;
                string str = "en";
                if ((args == null) || (args.Length < 1))
                {
                    flag = true;
                }
                if ((args != null) && (args.Length > 1))
                {
                    if (args[0].ToLowerInvariant() == "-installerversion")
                    {
                        if (Convert.ToInt32(args[1]) < CurrentInstallerBuild)
                        {
                            flag2 = true;
                        }
                    }
                    else if (!(args[0].ToLowerInvariant() == "-installer"))
                    {
                        flag = true;
                    }
                    if (args.Length > 2)
                    {
                        if (args[2].Length > 0)
                        {
                            str = args[2];
                        }
                        if ((args.Length > 3) && (args[3].Length > 0))
                        {
                            if (args[3] == "st")
                            {
                                steamInstall = true;
                            }
                            if (args[3] == "bp")
                            {
                                bigpointInstall = true;
                            }
                            if (args[3] == "bp2")
                            {
                                bigpointPartnerInstall = true;
                            }
                            if (args[3] == "ae")
                            {
                                aeriaInstall = true;
                            }
                            if (args[3] == "gf")
                            {
                                gamersFirstInstall = true;
                                if ((args.Length > 4) && (args[4].Length > 0))
                                {
                                    gamersFirstTokenMD5 = args[4];
                                }
                            }
                            if (args[3] == "arc")
                            {
                                if (args.Length > 4)
                                {
                                    arcUsername = args[4];
                                    arcInstall = true;
                                    if (arcUsername.Length <= 0)
                                    {
                                        arcLauncherStart = true;
                                    }
                                }
                                else
                                {
                                    arcLauncherStart = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    flag2 = true;
                }
                xmas_period = HolidayPeriods.xmas(DateTime.Now);
                if (arcLauncherStart)
                {
                    arc_launchClient(str);
                }
                else if (flag)
                {
                    MessageBox.Show(SK.Text("ProgramMain_Launch_Failure1", "This is not the game exe!") + Environment.NewLine + Environment.NewLine + SK.Text("ProgramMain_Launch_Failure2", "Please run Stronghold Kingdoms in the normal manner."), SK.Text("ProgramMain_Launch_Failure", "Stronghold Kingdoms Error"), MessageBoxButtons.OK);
                }
                else if (flag2 && !steamInstall)
                {
                    MessageBoxButtons oKCancel = MessageBoxButtons.OKCancel;
                    if (MessageBox.Show(SK.Text("ProgramMain_New_nInstaller", "A new version of the Updater/Installer is needed") + Environment.NewLine + SK.Text("ProgramMain_Must_Install", "You cannot Launch Stronghold Kingdoms until this is installed") + Environment.NewLine + Environment.NewLine + SK.Text("ProgramMain_Install_Now", "Do you wish to install this now?"), SK.Text("ProgramMain_Installer_Update", "Stronghold Kingdoms Installer Update"), oKCancel) == DialogResult.OK)
                    {
                        string path = InstallerUpdater.downloadSelfUpdater(new Uri("http://static.strongholdkingdoms.com/Kingdoms/kingdoms-setup-update-" + CurrentInstallerBuild.ToString() + ".exe"));
                        if ((path != null) && (path.Length > 0))
                        {
                            InstallerUpdater.runInstaller(path);
                        }
                    }
                }
                else
                {
                    bool flag3;
                    string name = @"Global\StrongholdKingdoms";
                    using (new Mutex(true, name, out flag3))
                    {
                        bool flag4;
                        try
                        {
                            OperatingSystem oSVersion = Environment.OSVersion;
                            if ((oSVersion.Platform == PlatformID.Win32NT) && (oSVersion.Version.Major >= 6))
                            {
                                SetProcessDPIAware();
                            }
                        }
                        catch (Exception)
                        {
                        }
                        AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);
                        Application.ThreadException += new ThreadExceptionEventHandler(Program.CurrentDomain_ThreadException);
                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        communityLangs = SKLocalization.scanForLanguages(GameEngine.getLangsPath());
                        installedLangCode = str;
                        mySettings = MySettings.load();
                        if (mySettings.LanguageIdent.Length == 0)
                        {
                            mySettings.LanguageIdent = str;
                        }
                        else if (mySettings.InstalledLanguageIdent != str)
                        {
                            mySettings.LanguageIdent = str;
                            mySettings.InstalledLanguageIdent = str;
                        }
                        if (!mySettings.OwnLanguageAvailableAndChecked)
                        {
                            string str6 = Thread.CurrentThread.CurrentCulture.TwoLetterISOLanguageName.ToLower();
                            if (str6 != mySettings.LanguageIdent)
                            {
                                if (str6 == "en")
                                {
                                    mySettings.OwnLanguageAvailableAndChecked = true;
                                }
                                else if ((((str6 == "de") || (str6 == "fr")) || ((str6 == "ru") || (str6 == "es"))) || (((str6 == "pl") || (str6 == "it")) || ((str6 == "tr") || (str6 == "pt"))))
                                {
                                    string str7 = SK.Text("ProgramMain_A_New_Language", "A New Language is available : ");
                                    switch (str6)
                                    {
                                        case "de":
                                            str7 = str7 + "Deutsch";
                                            break;

                                        case "fr":
                                            str7 = str7 + "Fran\x00e7ais";
                                            break;

                                        case "ru":
                                            str7 = str7 + "Русский";
                                            break;

                                        case "es":
                                            str7 = str7 + "Espa\x00f1ol";
                                            break;

                                        case "pl":
                                            str7 = str7 + "Polski";
                                            break;

                                        case "it":
                                            str7 = str7 + "Italiano";
                                            break;

                                        case "tr":
                                            str7 = str7 + "T\x00fcrk\x00e7e";
                                            break;

                                        case "pt":
                                            str7 = str7 + "Portugu\x00eas do Brasil";
                                            break;
                                    }
                                    if (MessageBox.Show(str7 + Environment.NewLine + SK.Text("ProgramMain_Use_New_Language", "Your system settings indicate you are using this language, do you wish to play Stronghold Kingdoms in this language?"), SK.Text("ProgramMain_NewLanguageAvailable", "New Language Available"), MessageBoxButtons.YesNo) == DialogResult.Yes)
                                    {
                                        mySettings.LanguageIdent = str6;
                                    }
                                    mySettings.OwnLanguageAvailableAndChecked = true;
                                }
                            }
                            else
                            {
                                mySettings.OwnLanguageAvailableAndChecked = true;
                            }
                        }
                        switch (mySettings.LanguageIdent)
                        {
                            case "en":
                            case "de":
                            case "fr":
                            case "ru":
                            case "es":
                            case "pl":
                            case "pt":
                            case "tr":
                            case "it":
                                SKLocalization.LoadLocalization(Application.StartupPath + @"\Localization\", mySettings.LanguageIdent);
                                goto Label_079B;

                            default:
                                flag4 = false;
                                foreach (SKLang lang in communityLangs)
                                {
                                    if (lang.id == mySettings.LanguageIdent)
                                    {
                                        SKLocalization.LoadLocalization(GameEngine.getLangsPath(), lang.id);
                                        if ((SKLocalization.Instance == null) || !SKLocalization.Instance.valid)
                                        {
                                            flag4 = false;
                                        }
                                        else
                                        {
                                            flag4 = true;
                                        }
                                        break;
                                    }
                                }
                                break;
                        }
                        if (!flag4)
                        {
                            mySettings.LanguageIdent = "en";
                            SKLocalization.LoadLocalization(Application.StartupPath + @"\Localization\", mySettings.LanguageIdent);
                        }
                    Label_079B:
                        if (steamInstall)
                        {
                            bool flag5 = false;
                            try
                            {
                                if (Steam_Init() > 0)
                                {
                                    steamActive = true;
                                    Steam_getTicket();
                                    string sessionid = BitConverter.ToString(steam_SessionTicket).Replace("-", "");
                                    XmlRpcAuthRequest req = new XmlRpcAuthRequest("", "", "", "", sessionid, "", "", "");
                                    XmlRpcAuthResponse response = XmlRpcAuthProvider.CreateForEndpoint(URLs.ProfileProtocol, URLs.ProfileServerAddressLogin, URLs.ProfileServerPort, URLs.ProfilePath).AuthenticateSteamAccount(req, null, null, 0x3a98);
                                    if (response.SuccessCode == 1)
                                    {
                                        flag5 = true;
                                        steamID = response.Message;
                                        steamEmail = response.UserGUID;
                                        mySettings.AutoLogin = false;
                                        if (steamEmail.Trim().Length > 0)
                                        {
                                            kingdomsAccountFound = true;
                                        }
                                        else
                                        {
                                            kingdomsAccountFound = false;
                                        }
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                steamActive = false;
                            }
                            if (!flag5)
                            {
                                MessageBox.Show(SK.Text("Steam_steam_required", "Stronghold Kingdoms requires the Steam Client to be running in Online mode."), SK.Text("Steam_error", "Steam Error"));
                                Application.Exit();
                                return;
                            }
                        }
                        if (!arcInstall || arc_login(arcUsername))
                        {
                            if (gamersFirstInstall && (gamersFirstTokenMD5.Length == 0))
                            {
                                MessageBox.Show(SK.Text("GF_token_error", "Unable to verify your GamersFirst identity. Please try again. If this issue persists, please contact support."), SK.Text("GF_Error", "GamersFirst Error"));
                                Application.Exit();
                            }
                            else
                            {
                                LoadingPanel panel = new LoadingPanel();
                                panel.init();
                                panel.Show();
                                panel.TopMost = true;
                                panel.BringToFront();
                                panel.Focus();
                                panel.BringToFront();
                                panel.TopMost = false;
                                string basePath = Application.StartupPath + @"\geckofx\xulrunner";
                                loadGeckoDLLs(basePath);
                                Xpcom.Initialize(basePath);
                                bool flag6 = testMutex();
                                if (!flag3 || flag6)
                                {
                                    MessageBox.Show(SK.Text("ProgramMain_Already_Running", "Already running") + "...", "Stronghold Kingdoms");
                                }
                                else
                                {
                                    bool flag7 = true;
                                    TimerCaps caps = new TimerCaps();
                                    timeGetDevCaps(ref caps, Marshal.SizeOf(caps));
                                    timerPeriod = Math.Max(caps.periodMin, 1);
                                    timeBeginPeriod(timerPeriod);
                                    DXTimer.Init();
                                    GameEngine engine = null;
                                    try
                                    {
                                        engine = new GameEngine();
                                    }
                                    catch (FileNotFoundException exception)
                                    {
                                        if (exception.FileName.Contains("irectX"))
                                        {
                                            GameEngine.displayDirectXError();
                                        }
                                        timeEndPeriod(timerPeriod);
                                        panel.Close();
                                        return;
                                    }
                                    GraphicsMgr mgr = new GraphicsMgr();
                                    int maxRes = 2;
                                    Screen primaryScreen = Screen.PrimaryScreen;
                                    int width = primaryScreen.Bounds.Width;
                                    int height = primaryScreen.Bounds.Height;
                                    if ((width < 0x400) || (height < 0x300))
                                    {
                                        MessageBoxButtons yesNo = MessageBoxButtons.YesNo;
                                        panel.Close();
                                        panel = null;
                                        if (MessageBox.Show(SK.Text("ProgramMain_Screen_Too_Small", "Your screen resolution is too small to run Stronghold Kingdoms") + Environment.NewLine + Environment.NewLine + SK.Text("ProgramMain_Try_Anyway", "Try to anyway?"), SK.Text("ProgramMain_Error", "Error"), yesNo) != DialogResult.Yes)
                                        {
                                            timeEndPeriod(timerPeriod);
                                            return;
                                        }
                                    }
                                    int num6 = width - 80;
                                    int num7 = height - 100;
                                    if (num6 < 0x3b0)
                                    {
                                        num6 = 0x3b0;
                                    }
                                    if (num7 < 0x29c)
                                    {
                                        num7 = 0x29c;
                                    }
                                    mySettings.Save();
                                    CastleMap.displayCollapsed = mySettings.CastleWalls;
                                    MainWindow newParentMainWindow = null;
                                    Form form = null;
                                    form = new MainWindow
                                    {
                                        Visible = false
                                    };
                                    if (arcInstall)
                                    {
                                        arc_init(form);
                                    }
                                    ((MainWindow)form).allowResizing(false);
                                    int screenWidth = num6;
                                    int screenHeight = num7;
                                    if (mySettings.ScreenWidth > 0)
                                    {
                                        screenWidth = mySettings.ScreenWidth;
                                    }
                                    if (mySettings.ScreenHeight > 0)
                                    {
                                        screenHeight = mySettings.ScreenHeight;
                                    }
                                    if (screenWidth > width)
                                    {
                                        screenWidth = width;
                                    }
                                    if (screenHeight > height)
                                    {
                                        screenHeight = height;
                                    }
                                    if (flag7)
                                    {
                                        form.MaximumSize = new Size(0xf00, 0x870);
                                        form.ClientSize = new Size(screenWidth, screenHeight);
                                    }
                                    else
                                    {
                                        form.ClientSize = new Size(0x3e8, 720);
                                        form.MaximumSize = new Size(0x41a, 760);
                                    }
                                    if (mySettings.Maximize)
                                    {
                                        form.WindowState = FormWindowState.Maximized;
                                    }
                                    form.Text = "Stronghold Kingdoms";
                                    ((MainWindow)form).allowResizing(true);
                                    newParentMainWindow = (MainWindow)form;
                                    InterfaceMgr.Instance.registerForm(form, newParentMainWindow);
                                    if (!engine.Initialise(mgr, maxRes, 2))
                                    {
                                        if (panel != null)
                                        {
                                            panel.Close();
                                            panel = null;
                                        }
                                    }
                                    else
                                    {
                                        SVG_Source instance = SVG_Source.Instance;
                                        Sound.setMusicState(mySettings.Music);
                                        GameEngine.Instance.AudioEngine.setMP3MasterVolume(((float)mySettings.MusicVolume) / 100f, 0);
                                        Sound.setSFXState(mySettings.SFX);
                                        Sound.setBattleSFXState(mySettings.BattleSFX);
                                        GameEngine.Instance.AudioEngine.setSFXMasterVolume(((float)mySettings.SFXVolume) / 100f);
                                        Sound.setEnvironmentalState(mySettings.Environmentals);
                                        GameEngine.Instance.AudioEngine.setEnvironmentalMasterVolume(((float)mySettings.EnvironmentalVolume) / 100f);
                                        bool flag8 = true;
                                        if (panel != null)
                                        {
                                            panel.Close();
                                            panel = null;
                                        }
                                        RemoteServices.Instance.initChannel();
                                        while (flag8)
                                        {
                                            engine.reLogin();
                                            flag8 = false;
                                            RemoteServices.Instance.UserID = -1;
                                            RemoteServices.Instance.set_CommonData_UserCallBack(null);
                                            while (RemoteServices.Instance.UserID < 0)
                                            {
                                                engine.installKeyboardHook();
                                                GameEngine.Instance.reLogin();
                                                GameEngine.Instance.clearServerDowntime();
                                                profileLogin = engine.getLoginWindow();
                                                if (profileLogin == null)
                                                {
                                                    profileLogin = new ProfileLoginWindow();
                                                    GameEngine.Instance.setProfileLogin(profileLogin);
                                                    profileLogin.Show();
                                                    profileLogin.init();
                                                }
                                                else
                                                {
                                                    profileLogin.openAfterCancel();
                                                }
                                                RemoteServices.Instance.clearQueues();
                                                while (profileLogin.Created && profileLogin.UserEntryMode)
                                                {
                                                    RemoteServices.Instance.processData();
                                                    Thread.Sleep(1);
                                                    DoEvents();
                                                    profileLogin.update();
                                                    StatTrackingClient.Instance().Update(0.01);
                                                }
                                                GameEngine.Instance.reLogin();
                                                form.Text = "Stronghold Kingdoms";
                                                if (WorldName != string.Empty)
                                                {
                                                    form.Text = form.Text + " - " + WorldName;
                                                }
                                                if (RemoteServices.Instance.UserID == -1)
                                                {
                                                    GameEngine.Instance.killLoadThread();
                                                    mySettings.Maximize = form.WindowState == FormWindowState.Maximized;
                                                    form.Close();
                                                    shutdown();
                                                    return;
                                                }
                                            }
                                            engine.showConnectingPopup();
                                            engine.World.loadLocalWorldData();
                                            engine.World.updateWorldMapOwnership();
                                            bool flag9 = true;
                                            while (flag9)
                                            {
                                                flag9 = false;
                                                VillageMap.loadVillageBuildingsGFX();
                                                while (engine.isStillLoading())
                                                {
                                                    Thread.Sleep(10);
                                                    DoEvents();
                                                    RemoteServices.Instance.processData();
                                                    GameEngine.Instance.updateConnectingPopup();
                                                }
                                                GameEngine.Instance.World.initSprites(GameEngine.Instance.GFX);
                                                GameEngine.Instance.resumeCommonRemote();
                                                engine.enableConnectingPopup();
                                                while (!GameEngine.Instance.World.isDownloadComplete())
                                                {
                                                    Thread.Sleep(10);
                                                    Application.DoEvents();
                                                    RemoteServices.Instance.processData();
                                                    GameEngine.Instance.updateConnectingPopup();
                                                    if (engine.loginCancelled())
                                                    {
                                                        break;
                                                    }
                                                }

                                                if (DataExport.controlForm != null)
                                                    DataExport.controlForm.Close();
                                                DataExport.controlForm = new ControlForm();
                                                DataExport.controlForm.Show();

                                                if (engine.pendingError())
                                                {
                                                    engine.updateConnectingPopup();
                                                    engine.forceRelogin();
                                                }
                                                if (!engine.loginCancelled())
                                                {
                                                    engine.World.saveFactionData();
                                                    engine.World.saveNamesData();
            #if DEBUG
                                                    DataExport.saveFactionData(engine.World);
                                                    DataExport.saveNamesData(engine.World);
            #endif
                                                    engine.enableConnectingPopup2();
                                                    while (engine.waitForConnectingPopupToClose())
                                                    {
                                                        Thread.Sleep(10);
                                                        DoEvents();
                                                        RemoteServices.Instance.processData();
                                                        if (engine.loginCancelled())
                                                        {
                                                            break;
                                                        }
                                                    }
                                                }
                                                if (RemoteServices.Instance.UserID == -1)
                                                {
                                                    GameEngine.Instance.killLoadThread();
                                                    mySettings.Maximize = form.WindowState == FormWindowState.Maximized;
                                                    form.Close();
                                                    shutdown();
                                                    return;
                                                }
                                                Sound.playMusic();

                                                bool flag10 = false;
                                                if (!engine.reLogin())
                                                {
                                                    InterfaceMgr.Instance.setupVillageName();
                                                    form.Show();
                                                    form.Visible = true;
                                                    newParentMainWindow.MainWindowLarge_SizeChanged(null, null);
                                                    GameEngine.Instance.lateStart();
                                                    if ((GameEngine.Instance.World.numVillagesOwned() > 0) && RemoteServices.Instance.ShowAdminMessage)
                                                    {
                                                        AdminInfoPopup.showMessage();
                                                    }
                                                    while (form.Created)
                                                    {
                                                        engine.run();
                                                        if (engine.reLogin())
                                                        {
                                                            form.Hide();
                                                            form.Visible = false;
                                                            engine.windowClosing();
                                                            if (!engine.quitting())
                                                            {
                                                                flag8 = true;
                                                            }
                                                            flag10 = true;
                                                            break;
                                                        }
                                                        StatTrackingClient.Instance().Update(0.01);
                                                        RemoteServices.Instance.processData();
                                                        if (form.Created)
                                                        {
                                                            Thread.Sleep(1);
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    flag8 = true;
                                                    flag10 = true;
                                                }
                                                if (!flag10)
                                                {
                                                    form.Hide();
                                                    form.Visible = false;
                                                    form = null;
                                                    newParentMainWindow = null;
                                                }
                                                engine.World.saveFactionData();
                                                engine.World.saveNamesData();
            #if DEBUG
                                                DataExport.saveFactionData(engine.World);
                                                DataExport.saveNamesData(engine.World);
            #endif
                                                Sound.stopMusic();
                                            }
                                        }
                                        try
                                        {
                                            if (form != null)
                                            {
                                                mySettings.Maximize = form.WindowState == FormWindowState.Maximized;
                                            }
                                        }
                                        catch (Exception)
                                        {
                                        }
                                        shutdown();
                                    }
                                }
                            }
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                File.WriteAllText("ex.txt", ex.ToString());
            }
            finally
            {
                if (DataExport.controlForm != null)
                    DataExport.controlForm.Close();
            }
        }
 public void init(int width, int height, GraphicsMgr graphics)
 {
     this.gfx = graphics;
     this.mapWidth = width;
     this.mapHeight = height;
     this.maskMap = new byte[width, height];
     this.clearMap();
     this.buildings.Clear();
 }
Esempio n. 30
0
 public bool Initialise(GraphicsMgr mgr, int maxRes, int curRes)
 {
     this.inputState = new MouseInputState();
     if (Program.mySettings.LanguageIdent == "de")
     {
         nfi = new CultureInfo("de-DE", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("de-DE", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("de-DE", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("de-DE", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "fr")
     {
         nfi = new CultureInfo("fr-FR", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("fr-FR", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("fr-FR", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("fr-FR", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "ru")
     {
         nfi = new CultureInfo("ru-RU", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("ru-RU", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("ru-RU", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("ru-RU", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "es")
     {
         nfi = new CultureInfo("es-ES", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("es-ES", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("es-ES", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("es-ES", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "pl")
     {
         nfi = new CultureInfo("pl-PL", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("pl-PL", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("pl-PL", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("pl-PL", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "it")
     {
         nfi = new CultureInfo("it-IT", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("it-IT", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("it-IT", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("it-IT", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "tr")
     {
         nfi = new CultureInfo("tr-TR", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("tr-TR", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("tr-TR", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("tr-TR", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else if (Program.mySettings.LanguageIdent == "pt")
     {
         nfi = new CultureInfo("pt-BR", false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo("pt-BR", false).NumberFormat;
         nfi_decimal1 = new CultureInfo("pt-BR", false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo("pt-BR", false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     else
     {
         nfi = new CultureInfo(CultureInfo.CurrentCulture.Name, false).NumberFormat;
         nfi.NumberDecimalDigits = 0;
         nfi_decimal = new CultureInfo(CultureInfo.CurrentCulture.Name, false).NumberFormat;
         nfi_decimal1 = new CultureInfo(CultureInfo.CurrentCulture.Name, false).NumberFormat;
         nfi_decimal1.NumberDecimalDigits = 1;
         nfi_decimal2 = new CultureInfo(CultureInfo.CurrentCulture.Name, false).NumberFormat;
         nfi_decimal2.NumberDecimalDigits = 2;
     }
     NewQuests.loadCSV();
     this.maxResolution = maxRes;
     this.currentResolution = curRes;
     this.gfx = mgr;
     this.m_doReLogin = false;
     this.villageToAbandon = -1;
     if (this.firstCall)
     {
         this.m_tickTimer = new System.Threading.Timer(new TimerCallback(this.TimerCallbackFunction), null, 0x21, 0x21);
     }
     if (this.gfx.InitControl(InterfaceMgr.Instance.getDXBasePanel(), Program.mySettings.AAMode) != null)
     {
         displayDirectXError();
         return false;
     }
     if (this.gfx.calcedAAMode > 0)
     {
         Program.mySettings.AAMode = this.gfx.calcedAAMode;
     }
     this.dxFont1.Family = "Tahoma";
     this.dxFont1.Height = 0x12;
     this.dxFont2.Family = "Arial";
     this.dxFont2.Weight = FontDesc.Weighting.Normal;
     this.dxFont2.Height = 0x12;
     this.gfx.Initialize();
     this.gfx.initRenderCallback(new GraphicsMgr.RenderCallback(this.render));
     this.gfx.initFont(this.dxFont1, this.dxFont2);
     this.m_WorkerThread = new Thread(new ThreadStart(this.loadThread));
     this.m_WorkerThread.Name = "Loader";
     GFXLibrary.Instance.loadResources();
     InterfaceMgr.Instance.mapPanelCreates();
     this.m_WorkerThread.Start();
     if (this.firstCall)
     {
         Thread.Sleep(100);
     }
     this.worldMapTypesData = new WorldMapTypes();
     if (this.firstCall)
     {
         this.audio = new Audio();
         this.audio.initAudio();
         VillageMap.loadVillageSounds();
         Sound.createPlayLists();
     }
     RemoteServices.Instance.set_CommonData_UserCallBack(new RemoteServices.CommonData_UserCallBack(this.remoteConnectionCommonHandler));
     InterfaceMgr.Instance.initInterfaces();
     OptionsPopup.registerCallback(new OptionsPopup.ResolutionChangeCallback(this.resolutionButtonChange));
     this.world.registerWorldZoomCallback(new WorldMap.WorldZoomCallback(this.worldZoomChange));
     this.world.capZoom(0.0);
     InterfaceMgr.Instance.getMainTabBar().registerTabChangeCallback(new MainTabBar2.TabChangeCallback(this.mainTabChange));
     InterfaceMgr.Instance.getVillageTabBar().registerTabChangeCallback(new VillageTabBar2.TabChangeCallback(this.villageTabChange));
     InterfaceMgr.Instance.getFactionTabBar().registerTabChangeCallback(new FactionTabBar2.TabChangeCallback(this.factionTabChange));
     RemoteServices.Instance.set_GetVillageBuildingsList_UserCallBack(new RemoteServices.GetVillageBuildingsList_UserCallBack(this.getVillageBuildingListCallBack));
     this.gfx.BGColor = WorldMap.SEACOLOR;
     this.lastTabID = -1;
     InterfaceMgr.Instance.ignoreStopDraw = true;
     DXPanel.skipPaint = true;
     this.mainTabChange(0);
     DXPanel.skipPaint = false;
     InterfaceMgr.Instance.ignoreStopDraw = false;
     this.firstCall = false;
     this.lastFullTickRegisterTime = this.lastFullTickTime = DXTimer.GetCurrentMilliseconds();
     return true;
 }
Esempio n. 31
0
 public void loadGFX(GraphicsMgr mgr)
 {
     this.gfx = mgr;
     if (Program.ShowSeasonalFXOption)
     {
         SnowSystem.getInstance().loadSnowTexture(this.gfx.D3DDevice, Application.StartupPath + @"\assets\snowball.png");
     }
     int mapElementsTexID = this.MapElementsTexID;
     if (!GameEngine.Instance.cancelLoading())
     {
         int effectLayerTexID = this.EffectLayerTexID;
         if (!GameEngine.Instance.cancelLoading())
         {
             int worldMapTilesTexID = this.WorldMapTilesTexID;
             if (!GameEngine.Instance.cancelLoading())
             {
                 int worldMapIconsTexID = this.WorldMapIconsTexID;
                 if (!GameEngine.Instance.cancelLoading())
                 {
                     this.worldMapLoaded = true;
                     this.ImageSurroundTexID2 = this.gfx.loadTextureFromBitmap((Bitmap) int_banquette_background_tile_orig);
                     this.ImageSurroundTexID3 = this.gfx.loadTextureFromBitmap((Bitmap) int_banquette_background_tile_tan);
                     Bitmap image = new Bitmap(0x40, 0x40);
                     image.MakeTransparent();
                     Graphics graphics = Graphics.FromImage(image);
                     graphics.DrawImage((Image) int_button_Q_normal, new Point(0, 0));
                     graphics.Dispose();
                     this.WikiHelpIconNormal = this.gfx.loadTextureFromBitmap(image);
                     image.Dispose();
                     image = new Bitmap(0x40, 0x40);
                     image.MakeTransparent();
                     graphics = Graphics.FromImage(image);
                     graphics.DrawImage((Image) int_button_Q_over, new Point(0, 0));
                     graphics.Dispose();
                     this.WikiHelpIconOver = this.gfx.loadTextureFromBitmap(image);
                     image.Dispose();
                     Bitmap newBitmap = new Bitmap(8, 8);
                     for (int i = 0; i < newBitmap.Height; i++)
                     {
                         for (int j = 0; j < newBitmap.Width; j++)
                         {
                             newBitmap.SetPixel(i, j, Color.FromArgb(0x40, ARGBColors.Black));
                         }
                     }
                     this.ImageSurroundShadowTexID = this.gfx.loadTextureFromBitmap(newBitmap);
                     int armourerAnimTexID = this.ArmourerAnimTexID;
                     if (!GameEngine.Instance.cancelLoading())
                     {
                         int bakerAnimTexID = this.BakerAnimTexID;
                         if (!GameEngine.Instance.cancelLoading())
                         {
                             int woodcutterAnimTexID = this.WoodcutterAnimTexID;
                             if (!GameEngine.Instance.cancelLoading())
                             {
                                 int stonemasonAnimTexID = this.StonemasonAnimTexID;
                                 if (!GameEngine.Instance.cancelLoading())
                                 {
                                     int ironMinerAnimTexID = this.IronMinerAnimTexID;
                                     if (!GameEngine.Instance.cancelLoading())
                                     {
                                         int farmerAnimTexID = this.FarmerAnimTexID;
                                         if (!GameEngine.Instance.cancelLoading())
                                         {
                                             int num12 = this.Farmer2AnimTexID;
                                             if (!GameEngine.Instance.cancelLoading())
                                             {
                                                 int num13 = this.Farmer3AnimTexID;
                                                 if (!GameEngine.Instance.cancelLoading())
                                                 {
                                                     int pitchworkerAnimTexID = this.PitchworkerAnimTexID;
                                                     if (!GameEngine.Instance.cancelLoading())
                                                     {
                                                         int dockworkerAnimTexID = this.DockworkerAnimTexID;
                                                         if (!GameEngine.Instance.cancelLoading())
                                                         {
                                                             int pigAnimTexID = this.PigAnimTexID;
                                                             if (!GameEngine.Instance.cancelLoading())
                                                             {
                                                                 int sheepAnimTexID = this.SheepAnimTexID;
                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                 {
                                                                     int chickenWhiteAnimTexID = this.ChickenWhiteAnimTexID;
                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                     {
                                                                         int chickenBrownAnimTexID = this.ChickenBrownAnimTexID;
                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                         {
                                                                             int metalWorkerAnimTexID = this.MetalWorkerAnimTexID;
                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                             {
                                                                                 int fletcherAnimTexID = this.FletcherAnimTexID;
                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                 {
                                                                                     int poleturnerAnimTexID = this.PoleturnerAnimTexID;
                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                     {
                                                                                         int blacksmithAnimTexID = this.BlacksmithAnimTexID;
                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                         {
                                                                                             int cowAnimTexID = this.CowAnimTexID;
                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                             {
                                                                                                 int num25 = this.Goods1TexID;
                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                 {
                                                                                                     int num26 = this.Goods2TexID;
                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                     {
                                                                                                         int townBuildindsTexID = this.TownBuildindsTexID;
                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                         {
                                                                                                             int num28 = this.Bld_9x9_1TexID;
                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                             {
                                                                                                                 int num29 = this.Bld_4x4_1TexID;
                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                 {
                                                                                                                     int num30 = this.Bld_8x8_1TexID;
                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                     {
                                                                                                                         int num31 = this.Woodcutter_animsTexID;
                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                         {
                                                                                                                             int num32 = this.Bld_6x6_1TexID;
                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                             {
                                                                                                                                 int num33 = this.Body_stonemasonTexID;
                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                 {
                                                                                                                                     int num34 = this.Body_iron_mine_workTexID;
                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                     {
                                                                                                                                         int num35 = this.Body_pitchworkerTexID;
                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                         {
                                                                                                                                             int num36 = this.Bld_13x13_1TexID;
                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                             {
                                                                                                                                                 int num37 = this.Bld_13x13_2TexID;
                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                 {
                                                                                                                                                     int num38 = this.Body_brewerTexID;
                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                     {
                                                                                                                                                         int num39 = this.Body_farmer_3TexID;
                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                         {
                                                                                                                                                             int num40 = this.Body_bakerTexID;
                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                             {
                                                                                                                                                                 int num41 = this.Bld_11x11_1TexID;
                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                 {
                                                                                                                                                                     int num42 = this.Bld_7x7_1TexID;
                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                     {
                                                                                                                                                                         int num43 = this.Bld_17x17_1TexID;
                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                         {
                                                                                                                                                                             int num44 = this.Body_tailorTexID;
                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                             {
                                                                                                                                                                                 int num45 = this.Body_carpenterTexID;
                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                 {
                                                                                                                                                                                     int num46 = this.Body_hunterTexID;
                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                     {
                                                                                                                                                                                         int num47 = this.Body_metalworkerTexID;
                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                         {
                                                                                                                                                                                             int num48 = this.Bld_5x5_1TexID;
                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                             {
                                                                                                                                                                                                 int num49 = this.Body_poleturnerTexID;
                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                 {
                                                                                                                                                                                                     int num50 = this.Body_fletcherTexID;
                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                     {
                                                                                                                                                                                                         int num51 = this.Body_blacksmithTexID;
                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                         {
                                                                                                                                                                                                             int num52 = this.Body_armourerTexID;
                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                             {
                                                                                                                                                                                                                 int num53 = this.Body_siegeworkerTexID;
                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                 {
                                                                                                                                                                                                                     int num54 = this.Bld_Various_01TexID;
                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                     {
                                                                                                                                                                                                                         int num55 = this.Anim_stocksTexID;
                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                         {
                                                                                                                                                                                                                             int num56 = this.Anim_stakeTexID;
                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                 int num57 = this.Anim_gibbetTexID;
                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                     int num58 = this.Anim_rackTexID;
                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                         int num59 = this.Anim_maypoleTexID;
                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                             int num60 = this.Anim_dancing_bearTexID;
                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                 int num61 = this.Body_theaterworkerTexID;
                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                     int num62 = this.Body_jesterTexID;
                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                         int num63 = this.Body_troubadourTexID;
                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                             int villageOverlaysAnimTexID = this.VillageOverlaysAnimTexID;
                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                 GC.Collect();
                                                                                                                                                                                                                                                                 GC.WaitForPendingFinalizers();
                                                                                                                                                                                                                                                                 int archerAnimTexID = this.ArcherAnimTexID;
                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                     int num66 = this.Archer2AnimTexID;
                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                         int pikemanAnimTexID = this.PikemanAnimTexID;
                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                             int swordsmanAnimTexID = this.SwordsmanAnimTexID;
                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                 int peasantAnimTexID = this.PeasantAnimTexID;
                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                     int num70 = this.Peasant2AnimTexID;
                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                         int catapultAnimTexID = this.CatapultAnimTexID;
                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                             int wolfAnimTexID = this.WolfAnimTexID;
                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                 int archerRedAnimTexID = this.ArcherRedAnimTexID;
                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                     int num74 = this.Archer2RedAnimTexID;
                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                         int pikemanRedAnimTexID = this.PikemanRedAnimTexID;
                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                             int swordsmanRedAnimTexID = this.SwordsmanRedAnimTexID;
                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                 int peasantRedAnimTexID = this.PeasantRedAnimTexID;
                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                     int num78 = this.Peasant2RedAnimTexID;
                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                         int archerGreenAnimTexID = this.ArcherGreenAnimTexID;
                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                             int num80 = this.Archer2GreenAnimTexID;
                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                 int pikemanGreenAnimTexID = this.PikemanGreenAnimTexID;
                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                     int swordsmanGreenAnimTexID = this.SwordsmanGreenAnimTexID;
                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                         int peasantGreenAnimTexID = this.PeasantGreenAnimTexID;
                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                             int num84 = this.Peasant2GreenAnimTexID;
                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                 int archerCarryAnimTexID = this.ArcherCarryAnimTexID;
                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                     int peasantCarryAnimTexID = this.PeasantCarryAnimTexID;
                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                         int pikemanCarryAnimTexID = this.PikemanCarryAnimTexID;
                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                             int swordsmanCarryAnimTexID = this.SwordsmanCarryAnimTexID;
                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                 GC.Collect();
                                                                                                                                                                                                                                                                                                                                                                 GC.WaitForPendingFinalizers();
                                                                                                                                                                                                                                                                                                                                                                 int knightAnimTexID = this.KnightAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                     int knightTopAnimTexID = this.KnightTopAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                         int captainAnimTexID = this.CaptainAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                             int missileTexID = this.MissileTexID;
                                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                 int num93 = this.Missile2TexID;
                                                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                     int animKillingPitsTexID = this.AnimKillingPitsTexID;
                                                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                         int fireTexID = this.FireTexID;
                                                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                             int oilPotAnimTexID = this.OilPotAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                                 int manOnFireTexID = this.ManOnFireTexID;
                                                                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                                     int num98 = this.Smoke1TexID;
                                                                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                                         int hpsBarsTexID = this.HpsBarsTexID;
                                                                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                                             int traderAnimTexID = this.TraderAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                                                 int traderHorseAnimTexID = this.TraderHorseAnimTexID;
                                                                                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                                                     int castleBackgroundTexID = this.CastleBackgroundTexID;
                                                                                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                                                         int castleSpritesTexID = this.CastleSpritesTexID;
                                                                                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                                                             int ballistaTexID = this.BallistaTexID;
                                                                                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                                                                 int armyAnimsTexID = this.ArmyAnimsTexID;
                                                                                                                                                                                                                                                                                                                                                                                                                                 if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                                 {
                                                                                                                                                                                                                                                                                                                                                                                                                                     int tutorialIconNormalID = this.TutorialIconNormalID;
                                                                                                                                                                                                                                                                                                                                                                                                                                     if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                                     {
                                                                                                                                                                                                                                                                                                                                                                                                                                         int tutorialIconOverID = this.TutorialIconOverID;
                                                                                                                                                                                                                                                                                                                                                                                                                                         if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                                         {
                                                                                                                                                                                                                                                                                                                                                                                                                                             int freeCardIconsID = this.FreeCardIconsID;
                                                                                                                                                                                                                                                                                                                                                                                                                                             if (!GameEngine.Instance.cancelLoading())
                                                                                                                                                                                                                                                                                                                                                                                                                                             {
                                                                                                                                                                                                                                                                                                                                                                                                                                                 GC.Collect();
                                                                                                                                                                                                                                                                                                                                                                                                                                                 GC.WaitForPendingFinalizers();
                                                                                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                         }
                                                                                                                                                                                                                                     }
                                                                                                                                                                                                                                 }
                                                                                                                                                                                                                             }
                                                                                                                                                                                                                         }
                                                                                                                                                                                                                     }
                                                                                                                                                                                                                 }
                                                                                                                                                                                                             }
                                                                                                                                                                                                         }
                                                                                                                                                                                                     }
                                                                                                                                                                                                 }
                                                                                                                                                                                             }
                                                                                                                                                                                         }
                                                                                                                                                                                     }
                                                                                                                                                                                 }
                                                                                                                                                                             }
                                                                                                                                                                         }
                                                                                                                                                                     }
                                                                                                                                                                 }
                                                                                                                                                             }
                                                                                                                                                         }
                                                                                                                                                     }
                                                                                                                                                 }
                                                                                                                                             }
                                                                                                                                         }
                                                                                                                                     }
                                                                                                                                 }
                                                                                                                             }
                                                                                                                         }
                                                                                                                     }
                                                                                                                 }
                                                                                                             }
                                                                                                         }
                                                                                                     }
                                                                                                 }
                                                                                             }
                                                                                         }
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
        public void updateStockpile(GraphicsMgr gfx, VillageMap vm)
        {
            if (this.baseSprite != null)
            {
                if (this.stockpileExtension == null)
                {
                    this.stockpileExtension = new VillageMapBuildingStockpileExtension();
                    for (int j = 0; j < 0x10; j++)
                    {
                        this.stockpileExtension.cell[j] = new SpriteWrapper();
                        this.stockpileExtension.cell[j].Visible = false;
                        this.stockpileExtension.cell[j].PosX = -96 + VillageMapBuildingStockpileExtension.stockpileLayout[j * 2];
                        this.stockpileExtension.cell[j].PosY = -43 + VillageMapBuildingStockpileExtension.stockpileLayout[(j * 2) + 1];
                        this.baseSprite.AddChild(this.stockpileExtension.cell[j]);
                        this.stockpileExtension.showGood(gfx, j, -1, 0);
                    }
                }
                for (int i = 0; i < 0x10; i++)
                {
                    this.stockpileExtension.showGood(gfx, i, -1, 0);
                }
                VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                if (!vm.getStockpileLevels(levels))
                {
                    for (int k = 0; k < 0x10; k++)
                    {
                        this.stockpileExtension.showGood(gfx, k, -1, 0);
                    }
                }
                else
                {
                    int index = 0;
                    if (levels.woodLevel > 13333248.0)
                    {
                        index = 12;
                    }
                    else if (levels.woodLevel > 3733248.0)
                    {
                        index = 11;
                    }
                    else if (levels.woodLevel > 1333248.0)
                    {
                        index = 10;
                    }
                    else if (levels.woodLevel > 373248.0)
                    {
                        index = 9;
                    }
                    else if (levels.woodLevel > 133248.0)
                    {
                        index = 8;
                    }
                    else if (levels.woodLevel > 37248.0)
                    {
                        index = 7;
                    }
                    else if (levels.woodLevel > 13248.0)
                    {
                        index = 6;
                    }
                    else if (levels.woodLevel > 3648.0)
                    {
                        index = 5;
                    }
                    else if (levels.woodLevel > 1248.0)
                    {
                        index = 4;
                    }
                    else if (levels.woodLevel > 288.0)
                    {
                        index = 3;
                    }
                    else if (levels.woodLevel > 48.0)
                    {
                        index = 2;
                    }
                    else if (levels.woodLevel > 0.0)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    int num4 = 0;
                    if (levels.stoneLevel > 13333248.0)
                    {
                        num4 = 12;
                    }
                    else if (levels.stoneLevel > 3733248.0)
                    {
                        num4 = 11;
                    }
                    else if (levels.stoneLevel > 1333248.0)
                    {
                        num4 = 10;
                    }
                    else if (levels.stoneLevel > 373248.0)
                    {
                        num4 = 9;
                    }
                    else if (levels.stoneLevel > 133248.0)
                    {
                        num4 = 8;
                    }
                    else if (levels.stoneLevel > 37248.0)
                    {
                        num4 = 7;
                    }
                    else if (levels.stoneLevel > 13248.0)
                    {
                        num4 = 6;
                    }
                    else if (levels.stoneLevel > 3648.0)
                    {
                        num4 = 5;
                    }
                    else if (levels.stoneLevel > 1248.0)
                    {
                        num4 = 4;
                    }
                    else if (levels.stoneLevel > 288.0)
                    {
                        num4 = 3;
                    }
                    else if (levels.stoneLevel > 48.0)
                    {
                        num4 = 2;
                    }
                    else if (levels.stoneLevel > 0.0)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 = 0;
                    }
                    int num5 = 0;
                    if (levels.ironLevel > 13333248.0)
                    {
                        num5 = 12;
                    }
                    else if (levels.ironLevel > 3733248.0)
                    {
                        num5 = 11;
                    }
                    else if (levels.ironLevel > 1333248.0)
                    {
                        num5 = 10;
                    }
                    else if (levels.ironLevel > 373248.0)
                    {
                        num5 = 9;
                    }
                    else if (levels.ironLevel > 133248.0)
                    {
                        num5 = 8;
                    }
                    else if (levels.ironLevel > 37248.0)
                    {
                        num5 = 7;
                    }
                    else if (levels.ironLevel > 13248.0)
                    {
                        num5 = 6;
                    }
                    else if (levels.ironLevel > 3648.0)
                    {
                        num5 = 5;
                    }
                    else if (levels.ironLevel > 1248.0)
                    {
                        num5 = 4;
                    }
                    else if (levels.ironLevel > 288.0)
                    {
                        num5 = 3;
                    }
                    else if (levels.ironLevel > 48.0)
                    {
                        num5 = 2;
                    }
                    else if (levels.ironLevel > 0.0)
                    {
                        num5 = 1;
                    }
                    else
                    {
                        num5 = 0;
                    }
                    int num6 = 0;
                    if (levels.pitchLevel > 4444416.0)
                    {
                        num6 = 12;
                    }
                    else if (levels.pitchLevel > 1244416.0)
                    {
                        num6 = 11;
                    }
                    else if (levels.pitchLevel > 444416.0)
                    {
                        num6 = 10;
                    }
                    else if (levels.pitchLevel > 124416.0)
                    {
                        num6 = 9;
                    }
                    else if (levels.pitchLevel > 44416.0)
                    {
                        num6 = 8;
                    }
                    else if (levels.pitchLevel > 12416.0)
                    {
                        num6 = 7;
                    }
                    else if (levels.pitchLevel > 4416.0)
                    {
                        num6 = 6;
                    }
                    else if (levels.pitchLevel > 1216.0)
                    {
                        num6 = 5;
                    }
                    else if (levels.pitchLevel > 416.0)
                    {
                        num6 = 4;
                    }
                    else if (levels.pitchLevel > 96.0)
                    {
                        num6 = 3;
                    }
                    else if (levels.pitchLevel > 16.0)
                    {
                        num6 = 2;
                    }
                    else if (levels.pitchLevel > 0.0)
                    {
                        num6 = 1;
                    }
                    else
                    {
                        num6 = 0;
                    }
                    for (int m = 0; m < 0x10; m++)
                    {
                        this.pilesUsed[m] = false;
                    }
                    int num8 = ((index + num4) + num5) + num6;
                    if (num8 > 0x10)
                    {
                        int num9 = 0x10;
                        int num10 = 0;
                        if (index >= 1)
                        {
                            num10++;
                        }
                        if (num4 >= 1)
                        {
                            num10++;
                        }
                        if (num5 >= 1)
                        {
                            num10++;
                        }
                        if (num6 >= 1)
                        {
                            num10++;
                        }
                        num9 -= num10;
                        double num11 = ((double) num9) / ((double) (num8 - num10));
                        PileOrderSort[] sortArray = new PileOrderSort[4];
                        int num12 = 0;
                        if (index > 1)
                        {
                            PileOrderSort sort;
                            sort = new PileOrderSort {
                                origPiles = index - 1,
                                numPiles = index - 1,
                                type = 0
                            };
                            sortArray[num12++] = sort;
                        }
                        if (num4 > 1)
                        {
                            PileOrderSort sort2;
                            sort2 = new PileOrderSort {
                                origPiles = num4 - 1,
                                numPiles = num4 - 1,
                                type = 3
                            };
                            sortArray[num12++] = sort2;
                        }
                        if (num5 > 1)
                        {
                            PileOrderSort sort3;
                            sort3 = new PileOrderSort {
                                origPiles = num5 - 1,
                                numPiles = num5 - 1,
                                type = 4
                            };
                            sortArray[num12++] = sort3;
                        }
                        if (num6 > 1)
                        {
                            PileOrderSort sort4;
                            sort4 = new PileOrderSort {
                                origPiles = num6 - 1,
                                numPiles = num6 - 1,
                                type = 5
                            };
                            sortArray[num12++] = sort4;
                        }
                        if (num12 > 1)
                        {
                            for (int num13 = 0; num13 < (num12 - 1); num13++)
                            {
                                for (int num14 = 0; num14 < (num12 - 1); num14++)
                                {
                                    if (sortArray[num14].numPiles < sortArray[num14 + 1].numPiles)
                                    {
                                        PileOrderSort sort5 = sortArray[num14];
                                        sortArray[num14] = sortArray[num14 + 1];
                                        sortArray[num14 + 1] = sort5;
                                    }
                                }
                            }
                        }
                        int num15 = 0;
                        for (int num16 = 0; num16 < num12; num16++)
                        {
                            sortArray[num16].numPiles = Math.Floor((double) (sortArray[num16].numPiles * num11));
                            num15 += (int) sortArray[num16].numPiles;
                        }
                        if (num15 < num9)
                        {
                            int num17 = num9 - num15;
                            for (int num18 = 0; num17 > 0; num18++)
                            {
                                int num19 = num18 % num12;
                                if (sortArray[num19].numPiles < sortArray[num19].origPiles)
                                {
                                    PileOrderSort sort1 = sortArray[num19];
                                    sort1.numPiles++;
                                    num17--;
                                }
                            }
                        }
                        if (index >= 1)
                        {
                            index = 1;
                        }
                        if (num4 >= 1)
                        {
                            num4 = 1;
                        }
                        if (num5 >= 1)
                        {
                            num5 = 1;
                        }
                        if (num6 >= 1)
                        {
                            num6 = 1;
                        }
                        for (int num20 = 0; num20 < num12; num20++)
                        {
                            int numPiles = (int) sortArray[num20].numPiles;
                            switch (sortArray[num20].type)
                            {
                                case 0:
                                    index += numPiles;
                                    break;

                                case 3:
                                    num4 += numPiles;
                                    break;

                                case 4:
                                    num5 += numPiles;
                                    break;

                                case 5:
                                    num6 += numPiles;
                                    break;
                            }
                        }
                        int num22 = ((index + num4) + num5) + num6;
                        if (num22 != 0x10)
                        {
                            index = 0;
                        }
                    }
                    int num23 = 0;
                    int num24 = 0;
                    for (int n = 0; n < index; n++)
                    {
                        num24 = this.woodPileOrder[num23++];
                        this.pilesUsed[num24] = true;
                        if (n != (index - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 6, 0x30);
                        }
                        else
                        {
                            int num26 = (((int) levels.woodLevel) - this.goods48Levels[index]) / this.goodsDividers[index];
                            this.stockpileExtension.showGood(gfx, num24, 6, Math.Min(num26, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num27 = 0; num27 < num5; num27++)
                    {
                        do
                        {
                            num24 = this.ironPileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num27 != (num5 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 8, 0x30);
                        }
                        else
                        {
                            int num28 = (((int) levels.ironLevel) - this.goods48Levels[num5]) / this.goodsDividers[num5];
                            this.stockpileExtension.showGood(gfx, num24, 8, Math.Min(num28, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num29 = 0; num29 < num4; num29++)
                    {
                        do
                        {
                            num24 = this.stonePileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num29 != (num4 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 7, 0x30);
                        }
                        else
                        {
                            int num30 = (((int) levels.stoneLevel) - this.goods48Levels[num4]) / this.goodsDividers[num4];
                            this.stockpileExtension.showGood(gfx, num24, 7, Math.Min(num30, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num31 = 0; num31 < num6; num31++)
                    {
                        do
                        {
                            num24 = this.pitchPileOrder[num23++];
                        }
                        while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num31 != (num6 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 9, 0x10);
                        }
                        else
                        {
                            int num32 = (((int) levels.pitchLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                            this.stockpileExtension.showGood(gfx, num24, 9, Math.Min(num32, 0x10));
                        }
                    }
                }
            }
        }
 public void updateInn(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.innExtension == null)
         {
             this.innExtension = new VillageMapBuildingInnExtension();
             for (int j = 0; j < 3; j++)
             {
                 this.innExtension.cell[j] = new SpriteWrapper();
                 this.innExtension.cell[j].Visible = false;
                 this.innExtension.cell[j].PosX = -80 + VillageMapBuildingInnExtension.innLayout[j * 2];
                 this.innExtension.cell[j].PosY = -44 + VillageMapBuildingInnExtension.innLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.innExtension.cell[j]);
                 this.innExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 3; i++)
         {
             this.innExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.InnLevels levels = new VillageMap.InnLevels();
         if (vm.getInnLevels(levels))
         {
             if (levels.aleLevel == 0.0)
             {
                 if (vm.m_effectiveAleRationsLevel > 0.0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     this.open = false;
                 }
             }
             else
             {
                 this.open = true;
                 int index = 0;
                 if (levels.aleLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.aleLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.aleLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.aleLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 if (index > 3)
                 {
                     index = 3;
                 }
                 for (int k = 0; k < index; k++)
                 {
                     if (k != (index - 1))
                     {
                         this.innExtension.showGood(gfx, k, 12, 0x10);
                     }
                     else
                     {
                         int num6 = (((int) levels.aleLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.innExtension.showGood(gfx, k, 12, Math.Min(num6, 0x10));
                     }
                 }
             }
         }
     }
 }
 public void updateGranary(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.granaryExtension == null)
         {
             this.granaryExtension = new VillageMapBuildingGranaryExtension();
             for (int j = 0; j < 0x15; j++)
             {
                 this.granaryExtension.cell[j] = new SpriteWrapper();
                 this.granaryExtension.cell[j].Visible = false;
                 this.granaryExtension.cell[j].PosX = 5 + VillageMapBuildingGranaryExtension.granaryLayout[j * 2];
                 this.granaryExtension.cell[j].PosY = -33 + VillageMapBuildingGranaryExtension.granaryLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.granaryExtension.cell[j]);
                 this.granaryExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 0x15; i++)
         {
             this.granaryExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.GranaryLevels levels = new VillageMap.GranaryLevels();
         if (vm.getGranaryLevels(levels))
         {
             if (vm.granaryOpenCount == 0)
             {
                 this.open = false;
             }
             double num3 = ((((levels.applesLevel + levels.breadLevel) + levels.cheeseLevel) + levels.fishLevel) + levels.meatLevel) + levels.vegLevel;
             if (num3 > 0.0)
             {
                 if (vm.granaryOpenCount > 0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     return;
                 }
                 int index = 0;
                 if (levels.meatLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.meatLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.meatLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.meatLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 int num5 = 0;
                 if (levels.vegLevel > 96.0)
                 {
                     num5 = 3;
                 }
                 else if (levels.vegLevel > 16.0)
                 {
                     num5 = 2;
                 }
                 else if (levels.vegLevel > 0.0)
                 {
                     num5 = 1;
                 }
                 else
                 {
                     num5 = 0;
                 }
                 int num6 = 0;
                 if (levels.cheeseLevel > 416.0)
                 {
                     num6 = 4;
                 }
                 else if (levels.cheeseLevel > 96.0)
                 {
                     num6 = 3;
                 }
                 else if (levels.cheeseLevel > 16.0)
                 {
                     num6 = 2;
                 }
                 else if (levels.cheeseLevel > 0.0)
                 {
                     num6 = 1;
                 }
                 else
                 {
                     num6 = 0;
                 }
                 int num7 = 0;
                 if (levels.applesLevel > 96.0)
                 {
                     num7 = 3;
                 }
                 else if (levels.applesLevel > 16.0)
                 {
                     num7 = 2;
                 }
                 else if (levels.applesLevel > 0.0)
                 {
                     num7 = 1;
                 }
                 else
                 {
                     num7 = 0;
                 }
                 int num8 = 0;
                 if (levels.fishLevel > 96.0)
                 {
                     num8 = 3;
                 }
                 else if (levels.fishLevel > 16.0)
                 {
                     num8 = 2;
                 }
                 else if (levels.fishLevel > 0.0)
                 {
                     num8 = 1;
                 }
                 else
                 {
                     num8 = 0;
                 }
                 int num9 = 0;
                 if (levels.breadLevel > 832.0)
                 {
                     num9 = 4;
                 }
                 else if (levels.breadLevel > 192.0)
                 {
                     num9 = 3;
                 }
                 else if (levels.breadLevel > 32.0)
                 {
                     num9 = 2;
                 }
                 else if (levels.breadLevel > 0.0)
                 {
                     num9 = 1;
                 }
                 else
                 {
                     num9 = 0;
                 }
                 int cellID = 0;
                 for (int k = 0; k < index; k++)
                 {
                     cellID = this.meatPileOrder[k];
                     if (k != (index - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x10, 0x10);
                     }
                     else
                     {
                         int num12 = (((int) levels.meatLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.granaryExtension.showGood(gfx, cellID, 0x10, Math.Min(num12, 0x10));
                     }
                 }
                 for (int m = 0; m < num5; m++)
                 {
                     cellID = this.vegPileOrder[m];
                     if (m != (num5 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 15, 0x10);
                     }
                     else
                     {
                         int num14 = (((int) levels.vegLevel) - this.goods16Levels[num5]) / this.goodsDividers[num5];
                         this.granaryExtension.showGood(gfx, cellID, 15, Math.Min(num14, 0x10));
                     }
                 }
                 for (int n = 0; n < num6; n++)
                 {
                     cellID = this.cheesePileOrder[n];
                     if (n != (num6 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x11, 0x10);
                     }
                     else
                     {
                         int num16 = (((int) levels.cheeseLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                         this.granaryExtension.showGood(gfx, cellID, 0x11, Math.Min(num16, 0x10));
                     }
                 }
                 for (int num17 = 0; num17 < num7; num17++)
                 {
                     cellID = this.applesPileOrder[num17];
                     if (num17 != (num7 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 13, 0x10);
                     }
                     else
                     {
                         int num18 = (((int) levels.applesLevel) - this.goods16Levels[num7]) / this.goodsDividers[num7];
                         this.granaryExtension.showGood(gfx, cellID, 13, Math.Min(num18, 0x10));
                     }
                 }
                 for (int num19 = 0; num19 < num8; num19++)
                 {
                     cellID = this.fishPileOrder[num19];
                     if (num19 != (num8 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x12, 0x10);
                     }
                     else
                     {
                         int num20 = (((int) levels.fishLevel) - this.goods16Levels[num8]) / this.goodsDividers[num8];
                         this.granaryExtension.showGood(gfx, cellID, 0x12, Math.Min(num20, 0x10));
                     }
                 }
                 for (int num21 = 0; num21 < num9; num21++)
                 {
                     cellID = this.breadPileOrder[num21];
                     if (num21 != (num9 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 14, 0x20);
                     }
                     else
                     {
                         int num22 = (((int) levels.breadLevel) - (this.goods16Levels[num9] * 2)) / this.goodsDividers[num9];
                         this.granaryExtension.showGood(gfx, cellID, 14, Math.Min(num22, 0x20));
                     }
                 }
             }
         }
     }
 }
Esempio n. 35
0
        public override void Draw()
        {
            var startingPosition = new Vector2(100, 100);
            var position         = startingPosition;
            var spacing          = 100;

            GraphicsMgr.CurrentColor = Color.White;             // Sprites are affected by current color too.

            // Sprites can't have static methods. So we are pulling them from sprite group.
            Default.Monofoxe.Draw(position, Default.Monofoxe.Origin);

            position += Vector2.UnitX * spacing * 2;

            // Setting a shader for the sprite.
            Resources.Effects.Seizure.SetWorldViewProjection(
                GraphicsMgr.CurrentWorld,
                GraphicsMgr.CurrentView,
                GraphicsMgr.CurrentProjection
                );

            GraphicsMgr.CurrentEffect = Resources.Effects.Seizure;
            // If you want to animate the sprite, you must pass a value from 0 to 1 to it.
            Default.Fire.Draw(_animation, position, Default.Fire.Origin);
            GraphicsMgr.CurrentEffect = null;

            position += Vector2.UnitX * spacing;

            // You can also access sprite's frame array, if you want to draw a specific frame.
            Default.Fire[2].Draw(position, Default.Fire.Origin);

            position += Vector2.UnitX * spacing;

            // You can scale, rotate srites and set custom origin point.

            Default.Fire.Draw(
                0.4f,
                position,
                new Vector2(Default.Fire.Width, Default.Fire.Height) / 2,
                new Vector2(1, 2) * (float)Math.Sin(_animation * Math.PI * 2 * 2),
                (float)(359 * _animation),
                Color.Red                 // Overrides CurrentColor.
                );


            position += Vector2.UnitX * spacing;

            // You also can draw only a part of the sprite.
            Default.Monofoxe.Draw(
                0,
                new Rectangle((int)(position.X), (int)(position.Y), 64, 64),
                new Rectangle(64, 64, 64, 64),
                0,
                Color.White
                );


            position  += Vector2.UnitY * spacing * 1.5f;
            position.X = 0;


            // You can extract raw texture from the frames. Note that you will get the whole texture atlas.
            var texture         = Default.Monofoxe[0].Texture;
            var texturePosition = Default.Monofoxe[0].TexturePosition;             // This will give you texture's position on the atlas.

            // But how are we gonna draw it? Monofoxe can't draw textures by itself.
            // We can use default Monogame's SpriteBatch for this.

            // But beforehand we must reset Monofoxe's graphics pipeline.
            // This method draws all batched graphics and resets internal graphics pipeline mode.
            GraphicsMgr.SwitchGraphicsMode(GraphicsMode.None);

            // After it, you can draw anything you like using any method.

            _batch.Begin(             // If you don't want to create new SpriteBatch, you can use GraphicsMgr.Batch instead.
                SpriteSortMode.Deferred,
                null,
                null,
                null,
                null,
                null,
                GraphicsMgr.CurrentView                 // Passig current transform matrix to match the camera.
                );
            _batch.Draw(texture, position, GraphicsMgr.CurrentColor);
            _batch.End();

            // After you're done, you can draw anything you like without switching graphics mode again.
            RectangleShape.Draw(position, position + new Vector2(texture.Width, texture.Height), true);


            position += Vector2.UnitX * 512;

            _surface.Draw(position);

            position += new Vector2(16, 150);

            GraphicsMgr.CurrentColor = Color.White;
            Text.CurrentFont         = Resources.Fonts.Arial;
            Text.Draw("This text is drawn using default" + Environment.NewLine + "Monogame spritefont.", position);
            position        += Vector2.UnitY * 48;
            Text.CurrentFont = Resources.Fonts.FancyFont;
            Text.Draw("This text is drawn using custom" + Environment.NewLine + "font made from a sprite.", position);
        }
        /// <summary>
        /// Sets Clipboard text and returns the content
        /// </summary>
        /// <returns></returns>
        public static string SetClipboardText(WorkerTask task, bool showDialog)
        {
            string clipboardText = "";

            switch (task.JobCategory)
            {
            case JobCategoryType.PICTURES:
            case JobCategoryType.SCREENSHOTS:
            case JobCategoryType.BINARY:
                ScreenshotsHistory = task.LinkManager;
                if (GraphicsMgr.IsValidImage(task.LocalFilePath))
                {
                    if (Engine.conf.ShowClipboardModeChooser || showDialog)
                    {
                        ClipboardOptions cmp = new ClipboardOptions(task);
                        cmp.Icon = Resources.zss_main;
                        if (showDialog)
                        {
                            cmp.ShowDialog();
                        }
                        else
                        {
                            cmp.Show();
                        }
                    }

                    if (task.MyImageUploader == ImageDestType.FILE)
                    {
                        clipboardText = task.LocalFilePath;
                    }
                    else
                    {
                        clipboardText = ScreenshotsHistory.GetUrlByType(Engine.conf.ClipboardUriMode).ToString().Trim();
                        if (task.MakeTinyURL)
                        {
                            string tinyUrl = ScreenshotsHistory.GetUrlByType(ClipboardUriType.FULL_TINYURL);
                            if (!string.IsNullOrEmpty(tinyUrl))
                            {
                                clipboardText = tinyUrl.Trim();
                            }
                        }
                    }
                }
                break;

            case JobCategoryType.TEXT:
                switch (task.Job)
                {
                case WorkerTask.Jobs.LANGUAGE_TRANSLATOR:
                    if (null != task.TranslationInfo)
                    {
                        clipboardText = task.TranslationInfo.Result.TranslatedText;
                    }
                    break;

                default:
                    if (!string.IsNullOrEmpty(task.RemoteFilePath))
                    {
                        clipboardText = task.RemoteFilePath;
                    }
                    else if (null != task.MyText)
                    {
                        clipboardText = task.MyText.LocalString;
                    }
                    else
                    {
                        clipboardText = task.LocalFilePath;
                    }
                    break;
                }
                break;
            }

            // after all this the clipboard text can be null

            if (!string.IsNullOrEmpty(clipboardText))
            {
                Engine.ClipboardUnhook();
                FileSystem.AppendDebug("Setting Clipboard with URL: " + clipboardText);
                Clipboard.SetText(clipboardText);

                // optional deletion link
                string linkdel = ScreenshotsHistory.GetDeletionLink();
                if (!string.IsNullOrEmpty(linkdel))
                {
                    FileSystem.AppendDebug("Deletion Link: " + linkdel);
                }

                Engine.zClipboardText = clipboardText;
                Engine.ClipboardHook();
            }
            return(clipboardText);
        }
        public void updateStockpile(GraphicsMgr gfx, VillageMap vm)
        {
            if (this.baseSprite != null)
            {
                if (this.stockpileExtension == null)
                {
                    this.stockpileExtension = new VillageMapBuildingStockpileExtension();
                    for (int j = 0; j < 0x10; j++)
                    {
                        this.stockpileExtension.cell[j]         = new SpriteWrapper();
                        this.stockpileExtension.cell[j].Visible = false;
                        this.stockpileExtension.cell[j].PosX    = -96 + VillageMapBuildingStockpileExtension.stockpileLayout[j * 2];
                        this.stockpileExtension.cell[j].PosY    = -43 + VillageMapBuildingStockpileExtension.stockpileLayout[(j * 2) + 1];
                        this.baseSprite.AddChild(this.stockpileExtension.cell[j]);
                        this.stockpileExtension.showGood(gfx, j, -1, 0);
                    }
                }
                for (int i = 0; i < 0x10; i++)
                {
                    this.stockpileExtension.showGood(gfx, i, -1, 0);
                }
                VillageMap.StockpileLevels levels = new VillageMap.StockpileLevels();
                if (!vm.getStockpileLevels(levels))
                {
                    for (int k = 0; k < 0x10; k++)
                    {
                        this.stockpileExtension.showGood(gfx, k, -1, 0);
                    }
                }
                else
                {
                    int index = 0;
                    if (levels.woodLevel > 13333248.0)
                    {
                        index = 12;
                    }
                    else if (levels.woodLevel > 3733248.0)
                    {
                        index = 11;
                    }
                    else if (levels.woodLevel > 1333248.0)
                    {
                        index = 10;
                    }
                    else if (levels.woodLevel > 373248.0)
                    {
                        index = 9;
                    }
                    else if (levels.woodLevel > 133248.0)
                    {
                        index = 8;
                    }
                    else if (levels.woodLevel > 37248.0)
                    {
                        index = 7;
                    }
                    else if (levels.woodLevel > 13248.0)
                    {
                        index = 6;
                    }
                    else if (levels.woodLevel > 3648.0)
                    {
                        index = 5;
                    }
                    else if (levels.woodLevel > 1248.0)
                    {
                        index = 4;
                    }
                    else if (levels.woodLevel > 288.0)
                    {
                        index = 3;
                    }
                    else if (levels.woodLevel > 48.0)
                    {
                        index = 2;
                    }
                    else if (levels.woodLevel > 0.0)
                    {
                        index = 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    int num4 = 0;
                    if (levels.stoneLevel > 13333248.0)
                    {
                        num4 = 12;
                    }
                    else if (levels.stoneLevel > 3733248.0)
                    {
                        num4 = 11;
                    }
                    else if (levels.stoneLevel > 1333248.0)
                    {
                        num4 = 10;
                    }
                    else if (levels.stoneLevel > 373248.0)
                    {
                        num4 = 9;
                    }
                    else if (levels.stoneLevel > 133248.0)
                    {
                        num4 = 8;
                    }
                    else if (levels.stoneLevel > 37248.0)
                    {
                        num4 = 7;
                    }
                    else if (levels.stoneLevel > 13248.0)
                    {
                        num4 = 6;
                    }
                    else if (levels.stoneLevel > 3648.0)
                    {
                        num4 = 5;
                    }
                    else if (levels.stoneLevel > 1248.0)
                    {
                        num4 = 4;
                    }
                    else if (levels.stoneLevel > 288.0)
                    {
                        num4 = 3;
                    }
                    else if (levels.stoneLevel > 48.0)
                    {
                        num4 = 2;
                    }
                    else if (levels.stoneLevel > 0.0)
                    {
                        num4 = 1;
                    }
                    else
                    {
                        num4 = 0;
                    }
                    int num5 = 0;
                    if (levels.ironLevel > 13333248.0)
                    {
                        num5 = 12;
                    }
                    else if (levels.ironLevel > 3733248.0)
                    {
                        num5 = 11;
                    }
                    else if (levels.ironLevel > 1333248.0)
                    {
                        num5 = 10;
                    }
                    else if (levels.ironLevel > 373248.0)
                    {
                        num5 = 9;
                    }
                    else if (levels.ironLevel > 133248.0)
                    {
                        num5 = 8;
                    }
                    else if (levels.ironLevel > 37248.0)
                    {
                        num5 = 7;
                    }
                    else if (levels.ironLevel > 13248.0)
                    {
                        num5 = 6;
                    }
                    else if (levels.ironLevel > 3648.0)
                    {
                        num5 = 5;
                    }
                    else if (levels.ironLevel > 1248.0)
                    {
                        num5 = 4;
                    }
                    else if (levels.ironLevel > 288.0)
                    {
                        num5 = 3;
                    }
                    else if (levels.ironLevel > 48.0)
                    {
                        num5 = 2;
                    }
                    else if (levels.ironLevel > 0.0)
                    {
                        num5 = 1;
                    }
                    else
                    {
                        num5 = 0;
                    }
                    int num6 = 0;
                    if (levels.pitchLevel > 4444416.0)
                    {
                        num6 = 12;
                    }
                    else if (levels.pitchLevel > 1244416.0)
                    {
                        num6 = 11;
                    }
                    else if (levels.pitchLevel > 444416.0)
                    {
                        num6 = 10;
                    }
                    else if (levels.pitchLevel > 124416.0)
                    {
                        num6 = 9;
                    }
                    else if (levels.pitchLevel > 44416.0)
                    {
                        num6 = 8;
                    }
                    else if (levels.pitchLevel > 12416.0)
                    {
                        num6 = 7;
                    }
                    else if (levels.pitchLevel > 4416.0)
                    {
                        num6 = 6;
                    }
                    else if (levels.pitchLevel > 1216.0)
                    {
                        num6 = 5;
                    }
                    else if (levels.pitchLevel > 416.0)
                    {
                        num6 = 4;
                    }
                    else if (levels.pitchLevel > 96.0)
                    {
                        num6 = 3;
                    }
                    else if (levels.pitchLevel > 16.0)
                    {
                        num6 = 2;
                    }
                    else if (levels.pitchLevel > 0.0)
                    {
                        num6 = 1;
                    }
                    else
                    {
                        num6 = 0;
                    }
                    for (int m = 0; m < 0x10; m++)
                    {
                        this.pilesUsed[m] = false;
                    }
                    int num8 = ((index + num4) + num5) + num6;
                    if (num8 > 0x10)
                    {
                        int num9  = 0x10;
                        int num10 = 0;
                        if (index >= 1)
                        {
                            num10++;
                        }
                        if (num4 >= 1)
                        {
                            num10++;
                        }
                        if (num5 >= 1)
                        {
                            num10++;
                        }
                        if (num6 >= 1)
                        {
                            num10++;
                        }
                        num9 -= num10;
                        double          num11     = ((double)num9) / ((double)(num8 - num10));
                        PileOrderSort[] sortArray = new PileOrderSort[4];
                        int             num12     = 0;
                        if (index > 1)
                        {
                            PileOrderSort sort;
                            sort = new PileOrderSort {
                                origPiles = index - 1,
                                numPiles  = index - 1,
                                type      = 0
                            };
                            sortArray[num12++] = sort;
                        }
                        if (num4 > 1)
                        {
                            PileOrderSort sort2;
                            sort2 = new PileOrderSort {
                                origPiles = num4 - 1,
                                numPiles  = num4 - 1,
                                type      = 3
                            };
                            sortArray[num12++] = sort2;
                        }
                        if (num5 > 1)
                        {
                            PileOrderSort sort3;
                            sort3 = new PileOrderSort {
                                origPiles = num5 - 1,
                                numPiles  = num5 - 1,
                                type      = 4
                            };
                            sortArray[num12++] = sort3;
                        }
                        if (num6 > 1)
                        {
                            PileOrderSort sort4;
                            sort4 = new PileOrderSort {
                                origPiles = num6 - 1,
                                numPiles  = num6 - 1,
                                type      = 5
                            };
                            sortArray[num12++] = sort4;
                        }
                        if (num12 > 1)
                        {
                            for (int num13 = 0; num13 < (num12 - 1); num13++)
                            {
                                for (int num14 = 0; num14 < (num12 - 1); num14++)
                                {
                                    if (sortArray[num14].numPiles < sortArray[num14 + 1].numPiles)
                                    {
                                        PileOrderSort sort5 = sortArray[num14];
                                        sortArray[num14]     = sortArray[num14 + 1];
                                        sortArray[num14 + 1] = sort5;
                                    }
                                }
                            }
                        }
                        int num15 = 0;
                        for (int num16 = 0; num16 < num12; num16++)
                        {
                            sortArray[num16].numPiles = Math.Floor((double)(sortArray[num16].numPiles * num11));
                            num15 += (int)sortArray[num16].numPiles;
                        }
                        if (num15 < num9)
                        {
                            int num17 = num9 - num15;
                            for (int num18 = 0; num17 > 0; num18++)
                            {
                                int num19 = num18 % num12;
                                if (sortArray[num19].numPiles < sortArray[num19].origPiles)
                                {
                                    PileOrderSort sort1 = sortArray[num19];
                                    sort1.numPiles++;
                                    num17--;
                                }
                            }
                        }
                        if (index >= 1)
                        {
                            index = 1;
                        }
                        if (num4 >= 1)
                        {
                            num4 = 1;
                        }
                        if (num5 >= 1)
                        {
                            num5 = 1;
                        }
                        if (num6 >= 1)
                        {
                            num6 = 1;
                        }
                        for (int num20 = 0; num20 < num12; num20++)
                        {
                            int numPiles = (int)sortArray[num20].numPiles;
                            switch (sortArray[num20].type)
                            {
                            case 0:
                                index += numPiles;
                                break;

                            case 3:
                                num4 += numPiles;
                                break;

                            case 4:
                                num5 += numPiles;
                                break;

                            case 5:
                                num6 += numPiles;
                                break;
                            }
                        }
                        int num22 = ((index + num4) + num5) + num6;
                        if (num22 != 0x10)
                        {
                            index = 0;
                        }
                    }
                    int num23 = 0;
                    int num24 = 0;
                    for (int n = 0; n < index; n++)
                    {
                        num24 = this.woodPileOrder[num23++];
                        this.pilesUsed[num24] = true;
                        if (n != (index - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 6, 0x30);
                        }
                        else
                        {
                            int num26 = (((int)levels.woodLevel) - this.goods48Levels[index]) / this.goodsDividers[index];
                            this.stockpileExtension.showGood(gfx, num24, 6, Math.Min(num26, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num27 = 0; num27 < num5; num27++)
                    {
                        do
                        {
                            num24 = this.ironPileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num27 != (num5 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 8, 0x30);
                        }
                        else
                        {
                            int num28 = (((int)levels.ironLevel) - this.goods48Levels[num5]) / this.goodsDividers[num5];
                            this.stockpileExtension.showGood(gfx, num24, 8, Math.Min(num28, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num29 = 0; num29 < num4; num29++)
                    {
                        do
                        {
                            num24 = this.stonePileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num29 != (num4 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 7, 0x30);
                        }
                        else
                        {
                            int num30 = (((int)levels.stoneLevel) - this.goods48Levels[num4]) / this.goodsDividers[num4];
                            this.stockpileExtension.showGood(gfx, num24, 7, Math.Min(num30, 0x30));
                        }
                    }
                    num23 = 0;
                    for (int num31 = 0; num31 < num6; num31++)
                    {
                        do
                        {
                            num24 = this.pitchPileOrder[num23++];
                        }while (this.pilesUsed[num24]);
                        this.pilesUsed[num24] = true;
                        if (num31 != (num6 - 1))
                        {
                            this.stockpileExtension.showGood(gfx, num24, 9, 0x10);
                        }
                        else
                        {
                            int num32 = (((int)levels.pitchLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                            this.stockpileExtension.showGood(gfx, num24, 9, Math.Min(num32, 0x10));
                        }
                    }
                }
            }
        }
 public void updateInn(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.innExtension == null)
         {
             this.innExtension = new VillageMapBuildingInnExtension();
             for (int j = 0; j < 3; j++)
             {
                 this.innExtension.cell[j]         = new SpriteWrapper();
                 this.innExtension.cell[j].Visible = false;
                 this.innExtension.cell[j].PosX    = -80 + VillageMapBuildingInnExtension.innLayout[j * 2];
                 this.innExtension.cell[j].PosY    = -44 + VillageMapBuildingInnExtension.innLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.innExtension.cell[j]);
                 this.innExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 3; i++)
         {
             this.innExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.InnLevels levels = new VillageMap.InnLevels();
         if (vm.getInnLevels(levels))
         {
             if (levels.aleLevel == 0.0)
             {
                 if (vm.m_effectiveAleRationsLevel > 0.0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     this.open = false;
                 }
             }
             else
             {
                 this.open = true;
                 int index = 0;
                 if (levels.aleLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.aleLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.aleLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.aleLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 if (index > 3)
                 {
                     index = 3;
                 }
                 for (int k = 0; k < index; k++)
                 {
                     if (k != (index - 1))
                     {
                         this.innExtension.showGood(gfx, k, 12, 0x10);
                     }
                     else
                     {
                         int num6 = (((int)levels.aleLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.innExtension.showGood(gfx, k, 12, Math.Min(num6, 0x10));
                     }
                 }
             }
         }
     }
 }
 public void updateGranary(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.baseSprite != null)
     {
         if (this.granaryExtension == null)
         {
             this.granaryExtension = new VillageMapBuildingGranaryExtension();
             for (int j = 0; j < 0x15; j++)
             {
                 this.granaryExtension.cell[j]         = new SpriteWrapper();
                 this.granaryExtension.cell[j].Visible = false;
                 this.granaryExtension.cell[j].PosX    = 5 + VillageMapBuildingGranaryExtension.granaryLayout[j * 2];
                 this.granaryExtension.cell[j].PosY    = -33 + VillageMapBuildingGranaryExtension.granaryLayout[(j * 2) + 1];
                 this.baseSprite.AddChild(this.granaryExtension.cell[j]);
                 this.granaryExtension.showGood(gfx, j, -1, 0);
             }
         }
         for (int i = 0; i < 0x15; i++)
         {
             this.granaryExtension.showGood(gfx, i, -1, 0);
         }
         VillageMap.GranaryLevels levels = new VillageMap.GranaryLevels();
         if (vm.getGranaryLevels(levels))
         {
             if (vm.granaryOpenCount == 0)
             {
                 this.open = false;
             }
             double num3 = ((((levels.applesLevel + levels.breadLevel) + levels.cheeseLevel) + levels.fishLevel) + levels.meatLevel) + levels.vegLevel;
             if (num3 > 0.0)
             {
                 if (vm.granaryOpenCount > 0)
                 {
                     this.open = true;
                 }
                 else
                 {
                     return;
                 }
                 int index = 0;
                 if (levels.meatLevel > 416.0)
                 {
                     index = 4;
                 }
                 else if (levels.meatLevel > 96.0)
                 {
                     index = 3;
                 }
                 else if (levels.meatLevel > 16.0)
                 {
                     index = 2;
                 }
                 else if (levels.meatLevel > 0.0)
                 {
                     index = 1;
                 }
                 else
                 {
                     index = 0;
                 }
                 int num5 = 0;
                 if (levels.vegLevel > 96.0)
                 {
                     num5 = 3;
                 }
                 else if (levels.vegLevel > 16.0)
                 {
                     num5 = 2;
                 }
                 else if (levels.vegLevel > 0.0)
                 {
                     num5 = 1;
                 }
                 else
                 {
                     num5 = 0;
                 }
                 int num6 = 0;
                 if (levels.cheeseLevel > 416.0)
                 {
                     num6 = 4;
                 }
                 else if (levels.cheeseLevel > 96.0)
                 {
                     num6 = 3;
                 }
                 else if (levels.cheeseLevel > 16.0)
                 {
                     num6 = 2;
                 }
                 else if (levels.cheeseLevel > 0.0)
                 {
                     num6 = 1;
                 }
                 else
                 {
                     num6 = 0;
                 }
                 int num7 = 0;
                 if (levels.applesLevel > 96.0)
                 {
                     num7 = 3;
                 }
                 else if (levels.applesLevel > 16.0)
                 {
                     num7 = 2;
                 }
                 else if (levels.applesLevel > 0.0)
                 {
                     num7 = 1;
                 }
                 else
                 {
                     num7 = 0;
                 }
                 int num8 = 0;
                 if (levels.fishLevel > 96.0)
                 {
                     num8 = 3;
                 }
                 else if (levels.fishLevel > 16.0)
                 {
                     num8 = 2;
                 }
                 else if (levels.fishLevel > 0.0)
                 {
                     num8 = 1;
                 }
                 else
                 {
                     num8 = 0;
                 }
                 int num9 = 0;
                 if (levels.breadLevel > 832.0)
                 {
                     num9 = 4;
                 }
                 else if (levels.breadLevel > 192.0)
                 {
                     num9 = 3;
                 }
                 else if (levels.breadLevel > 32.0)
                 {
                     num9 = 2;
                 }
                 else if (levels.breadLevel > 0.0)
                 {
                     num9 = 1;
                 }
                 else
                 {
                     num9 = 0;
                 }
                 int cellID = 0;
                 for (int k = 0; k < index; k++)
                 {
                     cellID = this.meatPileOrder[k];
                     if (k != (index - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x10, 0x10);
                     }
                     else
                     {
                         int num12 = (((int)levels.meatLevel) - this.goods16Levels[index]) / this.goodsDividers[index];
                         this.granaryExtension.showGood(gfx, cellID, 0x10, Math.Min(num12, 0x10));
                     }
                 }
                 for (int m = 0; m < num5; m++)
                 {
                     cellID = this.vegPileOrder[m];
                     if (m != (num5 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 15, 0x10);
                     }
                     else
                     {
                         int num14 = (((int)levels.vegLevel) - this.goods16Levels[num5]) / this.goodsDividers[num5];
                         this.granaryExtension.showGood(gfx, cellID, 15, Math.Min(num14, 0x10));
                     }
                 }
                 for (int n = 0; n < num6; n++)
                 {
                     cellID = this.cheesePileOrder[n];
                     if (n != (num6 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x11, 0x10);
                     }
                     else
                     {
                         int num16 = (((int)levels.cheeseLevel) - this.goods16Levels[num6]) / this.goodsDividers[num6];
                         this.granaryExtension.showGood(gfx, cellID, 0x11, Math.Min(num16, 0x10));
                     }
                 }
                 for (int num17 = 0; num17 < num7; num17++)
                 {
                     cellID = this.applesPileOrder[num17];
                     if (num17 != (num7 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 13, 0x10);
                     }
                     else
                     {
                         int num18 = (((int)levels.applesLevel) - this.goods16Levels[num7]) / this.goodsDividers[num7];
                         this.granaryExtension.showGood(gfx, cellID, 13, Math.Min(num18, 0x10));
                     }
                 }
                 for (int num19 = 0; num19 < num8; num19++)
                 {
                     cellID = this.fishPileOrder[num19];
                     if (num19 != (num8 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 0x12, 0x10);
                     }
                     else
                     {
                         int num20 = (((int)levels.fishLevel) - this.goods16Levels[num8]) / this.goodsDividers[num8];
                         this.granaryExtension.showGood(gfx, cellID, 0x12, Math.Min(num20, 0x10));
                     }
                 }
                 for (int num21 = 0; num21 < num9; num21++)
                 {
                     cellID = this.breadPileOrder[num21];
                     if (num21 != (num9 - 1))
                     {
                         this.granaryExtension.showGood(gfx, cellID, 14, 0x20);
                     }
                     else
                     {
                         int num22 = (((int)levels.breadLevel) - (this.goods16Levels[num9] * 2)) / this.goodsDividers[num9];
                         this.granaryExtension.showGood(gfx, cellID, 14, Math.Min(num22, 0x20));
                     }
                 }
             }
         }
     }
 }
 public VillageMapPerson(GraphicsMgr newGfx)
 {
     this.gfx = newGfx;
 }
 public void initStorageBuilding(GraphicsMgr gfx, VillageMap vm)
 {
     if (this.buildingType == 2)
     {
         this.updateStockpile(gfx, vm);
     }
     if (this.buildingType == 3)
     {
         this.updateGranary(gfx, vm);
     }
     if (this.buildingType == 0x23)
     {
         this.updateInn(gfx, vm);
     }
 }