Ejemplo n.º 1
0
        static public void DrawText(string text, int x, int y)
        {
            var dx = x;
            var dy = y;

            for (int i = 0; i < text.Length; i++)
            {
                var b = (byte)text[i];
                if (b == 32)
                {
                    dx += fw;
                }
                else if (b == 10)
                {
                    dx  = x;
                    dy += fh;
                }
                else if (b > 32 && b < 127)
                {
                    if (!CharPics.ContainsKey(b))
                    {
                        var q = QuickStream.OpenEmbedded($"SysFont.{b}.png");
                        if (q != null)
                        {
                            CharPics[b] = TQMG.GetImage(q);
                            Debug.WriteLine($"Loaded character {b} => {text[i]}");
                        }
                    }
                    if (CharPics.ContainsKey(b))   // NO ELSE! That won't cause the desired effect
                    {
                        try {
                            var cp = CharPics[b];
                            cp.Draw(dx, dy);
                            if (fw < cp.Width)
                            {
                                fw = cp.Width;
                            }
                            if (fh < cp.Height)
                            {
                                fh = cp.Height;
                            }
                            dx += fw;
                            if (dx + fw > TQMG.ScrWidth)
                            {
                                dx  = x;
                                dy += fh;
                            }
                        } catch (Exception E) {
                            Debug.Print($"Caught: {E.Message}");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private BubbleGraphics(Lua state, string id)
        {
            var bt     = QuickStream.OpenEmbedded("Graphics.nil");
            var script = bt.ReadString((int)bt.Size);

            vm = id;
            bt.Close();
            state["BubbleGraphics"] = this;
            SBubble.DoNIL(id, script, "Graphics init script");
            SBubble.State(id).DoString("Color = SetColor", "HACKING!"); // Prevent confusion since the console's not really accesible anyway
        }
Ejemplo n.º 3
0
        static public void Init(string astatename)
        {
            var Kth = new KthuraBubble();
            var S   = SBubble.State(astatename).state;

            S["BKTHURA"]  = Kth;
            Kth.statename = astatename;
            var bt = QuickStream.OpenEmbedded("KthuraBubble.nil");
            var l  = bt.ReadString((int)bt.Size);

            bt.Close();
            SBubble.DoNIL(astatename, l, "Kthura API Link Script");
        }
Ejemplo n.º 4
0
        static public void GoError(string ct, string message, string trace)
        {
            blocked = true;
            BubConsole.WriteLine($"ERROR>{message}", 255, 0, 0);
            Debug.WriteLine($"{ct}: {message}\nTraceback:\n{trace}\n\n");
            if (crashed)
            {
                return;
            }
            crashed = true;
            var s = QuickStream.OpenEmbedded("Death.png");

            if (s == null)
            {
                Debug.WriteLine("ERROR! Trying to read Death resulted into null!");
            }
            s.Position = 0;
            Death      = TQMG.GetImage(s);
            sct        = ct;
            smsg       = message;
            strace     = trace;
            FlowManager.GoHardFlow(new Error(), true);
        }
Ejemplo n.º 5
0
        static public void TextSizes(string text, ref int w, ref int h, int x = 0)
        {
            var dx = x;
            var dy = 0;
            // Needed due to C#'s primitive nature!
            var tw = w;
            var th = h;

            void update()
            {
                if (dx > tw)
                {
                    tw = dx;
                }
                if (dy > th)
                {
                    th = dy + fh;
                }
            }

            for (int i = 0; i < text.Length; i++)
            {
                var b = (byte)text[i];
                if (b == 32)
                {
                    dx += fw;
                    update();
                }
                else if (b == 10)
                {
                    dx  = x;
                    dy += fh;
                    update();
                }
                else if (b > 32 && b < 127)
                {
                    if (!CharPics.ContainsKey(b))
                    {
                        var q = QuickStream.OpenEmbedded($"SysFont.{b}.png");
                        if (q != null)
                        {
                            CharPics[b] = TQMG.GetImage(q);
                            Debug.WriteLine($"Loaded character {b} => {text[i]}");
                        }
                    }
                    if (CharPics.ContainsKey(b))   // NO ELSE! That won't cause the desired effect
                    {
                        try {
                            var cp = CharPics[b];
                            if (fw < cp.Width)
                            {
                                fw = cp.Width;
                            }
                            if (fh < cp.Height)
                            {
                                fh = cp.Height;
                            }
                            dx += fw;
                            update();
                            if (dx + fw > TQMG.ScrWidth)
                            {
                                dx  = x;
                                dy += fh;
                                update();
                            }
                        } catch (Exception E) {
                            Debug.Print($"Caught: {E.Message}");
                        }
                    }
                }
            }
            w = tw;
            h = th;
        }