Beispiel #1
0
        public override void DrawObstacle(KthuraObject obj, int ix = 0, int iy = 0, int scrollx = 0, int scrolly = 0)
        {
            var tx = GetTex(obj);

            if (tx != null)
            {
                TQMG.Color((byte)obj.R, (byte)obj.G, (byte)obj.B);
                //TQMG.SetAlphaFloat((float)obj.Alpha1000 / 1000);
                TQMG.SetAlpha((byte)obj.Alpha255);
                //TQMG.RotateRAD((float)obj.RotationRadians);
                TQMG.RotateDEG(obj.RotationDegrees);
                TQMG.Scale(obj.ScaleX, obj.ScaleY);
                if (obj.AnimFrame < 0 || obj.AnimFrame >= tx.Frames)
                {
                    obj.AnimFrame = 0;
                }
                tx.XDraw(obj.x + ix - scrollx, obj.y + iy - scrolly, obj.AnimFrame);
                TQMG.Scale(1000, 1000);
                TQMG.RotateRAD(0);
                TQMG.SetAlpha(255);
            }
            else
            {
                CrashOnNoTex?.Invoke($"Obstacle-texture '{obj.Texture}' did somehow not load?");
            }
        }
Beispiel #2
0
        public static void TexSizes(KthuraObject obj, ref int w, ref int h)
        {
            var tex = me.GetTex(obj);

            w = tex.Width;
            h = tex.Height;
        }
Beispiel #3
0
        public override void DrawStretchedArea(KthuraObject obj, int ix = 0, int iy = 0, int scrollx = 0, int scrolly = 0)
        {
            var tx = GetTex(obj);

            TQMG.Color((byte)obj.R, (byte)obj.G, (byte)obj.B);
            TQMG.SetAlpha((byte)obj.Alpha255);
            if (tx != null)
            {
                tx.StretchDraw(obj.x + ix - scrollx, obj.y + iy - scrolly, obj.w, obj.h, obj.AnimFrame);
            }
            TQMG.SetAlpha(255);
        }
Beispiel #4
0
        public override void AnimReset(KthuraObject obj)
        {
            var tex = GetTex(obj);

            if (tex == null)
            {
                return;
            }
            if (obj.AnimFrame >= tex.Frames)
            {
                obj.AnimFrame = 0;
            }
        }
Beispiel #5
0
        public override void DrawTiledArea(KthuraObject obj, int ix = 0, int iy = 0, int scrollx = 0, int scrolly = 0)
        {
            var tx = GetTex(obj);

            TQMG.Color((byte)obj.R, (byte)obj.G, (byte)obj.B);
            //TQMG.SetAlphaFloat((float)obj.Alpha1000 / 1000);
            TQMG.SetAlpha((byte)obj.Alpha255);
            if (tx != null)
            {
                TQMG.Tile(tx, obj.insertx, obj.inserty, obj.x + ix - scrollx, obj.y + iy - scrolly, obj.w, obj.h, obj.AnimFrame);
            }
            TQMG.SetAlpha(255);
        }
Beispiel #6
0
        public override int ObjectWidth(KthuraObject obj)
        {
            TQMGImage tex;

            switch (obj.kind)
            {
            case "Zone":
            case "TiledArea":
            case "StretchedArea":
                return(obj.w);

            case "Obstacle":
            case "Pic":
            case "Actor":
                tex = GetTex(obj);
                return(tex.Width);

            default:
                return(0);
            }
        }
Beispiel #7
0
 abstract public int ObjectWidth(KthuraObject obj);
Beispiel #8
0
 abstract public void AnimReset(KthuraObject obj);
Beispiel #9
0
 abstract public void DrawStretchedArea(KthuraObject obj, int ix = 0, int iy = 0, int scrollx = 0, int scrolly = 0);
Beispiel #10
0
 abstract public void DrawPic(KthuraObject obj, int ix           = 0, int iy = 0, int scrollx = 0, int scrolly = 0);
Beispiel #11
0
        TQMGImage GetTex(KthuraObject obj)
        {
            var file  = obj.Texture;
            var kind  = obj.kind;
            var lay   = obj.Parent;
            var map   = lay.Parent;
            var mfile = qstr.StripExt(file);

            if (qstr.ExtractExt(file.ToUpper()) == "PNG" && map.TextureJCR.Exists($"{mfile}.frames") && map.TextureJCR.DirExists($"{mfile}.jpbf"))
            {
                var rfile = $"{mfile}.jpbf";
                switch (AutoBundle)
                {
                case TAutoBundle.Off: break;

                case TAutoBundle.AutomaticallyFixObject:
                    obj.Texture = rfile;
                    // Fallthrough... Otherwise not supported in C#, so this is the only way to do it (bad bad Microsoft)
                    goto case TAutoBundle.ReplaceInLoadOnly;

                case TAutoBundle.ReplaceInLoadOnly:
                    file = rfile;
                    break;
                }
            }
            if (map != LastUsedMap)
            {
                Textures.Clear();                     // Only store texture per map. Will take too much RAM otherwise!
            }
            LastUsedMap = map;
            var tag = $"{kind}::{file}";

            if (!Textures.ContainsKey(tag))
            {
                if (qstr.ExtractExt(file.ToUpper()) == "JPBF")
                {
                    Textures[tag] = TQMG.GetBundle(map.TextureJCR, $"{file}/");
                    //Bubble.BubConsole.WriteLine($"KTHURA DRAW DEBUG: Loading Bundle {file}", 255, 255, 0); // debug! (must be on comment when not in use)
                }
                else
                {
                    if (map.TextureJCR == null)
                    {
                        Debug.WriteLine("TextureJCR is null???");
                    }
                    var bt = map.TextureJCR.ReadFile(file);
                    if (bt == null)
                    {
                        if (NoTexture != null)
                        {
                            Textures[tag] = NoTexture; //TQMG.GetImage(NoTexture.GetTex(0));
                            System.Console.Beep();
                            Debug.WriteLine($"Texture {file} for {tag} could not be loaded , so set to alternet picture in stead ({UseJCR6.JCR6.JERROR})");
                            //return NoTexture;
                        }
                        else
                        {
                            CrashOnNoTex?.Invoke($"Couldn't open texture file {file} for {tag}");
                            Debug.WriteLine($"Couldn't open texture file {file} for {tag}");
                            return(null);
                        }
                    }
                    else
                    {
                        Textures[tag] = TQMG.GetImage(bt);
                        if (Textures[tag] == null)
                        {
                            if (NoTexture != null)
                            {
                                Textures[tag] = NoTexture;
                                System.Console.Beep();
                                Debug.WriteLine($"Texture {tag} could not be loaded, so set to alternet picture in stead");
                            }
                            else
                            {
                                CrashOnNoTex?.Invoke($"Texture `{file}` didn't load at all on tag {tag}.\n{UseJCR6.JCR6.JERROR}");
                            }
                        }
                    }
                }
                if (Textures[tag].Frames == 0)
                {
                    CrashOnNoTex?.Invoke($"Texture `{file}` for tag `{tag}` has no frames");
                }
                if (obj.kind == "Obstacle" || obj.kind == "Actor")
                {
                    Textures[tag].HotBottomCenter();
                }
            }
            return(Textures[tag]);
        }
Beispiel #12
0
 public static int TexWidth(KthuraObject obj)
 {
     int w = 0, h = 0; TexSizes(obj, ref w, ref h); return(w);
 }
Beispiel #13
0
 override public void DrawPic(KthuraObject obj, int ix = 0, int iy = 0, int scrollx = 0, int scrolly = 0)
 {
     DrawObstacle(obj, ix, iy, scrollx, scrolly); // Seems odd, but trust me... :-P
 }
Beispiel #14
0
 public static int TexHeight(KthuraObject obj)
 {
     int w = 0, h = 0; TexSizes(obj, ref w, ref h); return(h);
 }
Beispiel #15
0
 abstract public int ObjectHeight(KthuraObject obj);
Beispiel #16
0
 abstract public bool HasTexture(KthuraObject obj);
Beispiel #17
0
        public override bool HasTexture(KthuraObject obj)
        {
            var tag = $"{obj.kind}::{obj.Texture}";

            return(Textures.ContainsKey(tag));
        }