コード例 #1
0
        // This method processes the main program. Main() ends up keeping track of whether it should kill
        // the program while this guy does all the actual hard work of drawing, checking mails, etc.
        static void ProcessStuff()
        {
            Stuff.Init();

            Account.Init();

            // Loads the font into memory from the .map files
            font = new CharFont("CharFiles/MizConsole/");
            Actions.Actions.Init(font);

            Thread.Sleep(1000);

            HwndObject obj;

            if (GetPaintHwnd(out obj))
            {
                Console.ForegroundColor = Colors.Success;
                Console.WriteLine("[Program] Paint Hwnd found! using: " + obj.Text);
                obj.Activate();
                WindowScrape.Static.HwndInterface.ShowWindow(obj.Hwnd, 3);
            }
            else
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("[Program] Paint Hwnd not found.");
                Input.OpenPaint();
                if (!ForceGetPaintHwnd(out obj))
                {
                    Console.ForegroundColor = Colors.Error;
                    Console.WriteLine("[Program] ERROR: Can't find Paint Hwnd. Process aborted.");
                    return;
                }
            }

            Thread.Sleep(1000);

            if (obj.Location.X > 10 && obj.Location.Y > 10 && obj.Size.Width < Stuff.ScreenWidth - 50 && obj.Size.Height < Stuff.ScreenHeight - 50)
            {
                Console.ForegroundColor = Colors.Message;
                Console.WriteLine("Paint window not maximized, maximizing...");
                Input.MoveTo(new Point(obj.Location.X + obj.Size.Width - 69, obj.Location.Y + 3));
                Input.RegisterClick();
                Thread.Sleep(100);
            }

            watch = Stopwatch.StartNew();
            queue = new Queue <IAction>(64);
            Console.ForegroundColor = Colors.Success;
            Console.WriteLine("Stopwatch started. Entering main loop...");

            Input.PaintSelectBrush();
            new SimpleWrite(font, "Welcome to PaintDrawer! What shall I draw for you, kind sir?", 70).Act();

            System.Text.StringBuilder build = new System.Text.StringBuilder(256);
            for (int i = 32; i < CharFont.MaxCharNumericValue; i++)
            {
                if (font.DoesCharExist((char)i))
                {
                    build.Append((char)i);
                }
            }
            new SimpleWrite(font, build.ToString(), 70).Act();

            Actions.Actions.CreateSimpleWrite(font, "Este es un mensaje especial! Estas durmiendo en un estado de coma, metimos esto en tu cabeza pero no sabemos a donde va a terminar, no tenemos idea que hacer con vos, por favor despertate! no porque te extrañemos pero yo que se...").Act();
            LastDraw = -60;

            while (true)
            {
                Account.AddNewToQueue(queue);

                if (queue.Count == 0 && Time - LastDraw > 5 * 60)
                {
                    // More than X minutes passed since the last draw! Let's add something random then...
                    queue.Enqueue(Actions.Actions.RandomAction);
                }

                if (queue.Count != 0 && Time - LastDraw > 1 * 60)
                {
                    // Give all texts at least a minute before erasing 'em... and drawing something else
                    Input.PaintClearImage();
                    Input.PaintSelectBrush();
                    LastDraw = Time;
                    queue.Dequeue().Act();
                }
                else
                {
                    Thread.Sleep(2000);
                }
            }
        }