new public static GFX_MODE_LIST get_gfx_mode_list(int card)
        {
            IntPtr        p   = AllegroAPI.get_gfx_mode_list(card);
            GFX_MODE_LIST ret = (GFX_MODE_LIST)Marshal.PtrToStructure(p, typeof(GFX_MODE_LIST));

            // Saves the original unmanaged memory address
            ret.p = p;
            return(ret);
        }
        new public static string[] get_config_argv(string section, string name, ref int argc)
        {
            ManagedPointer mp = new ManagedPointer(AllegroAPI.get_config_argv(section, name, ref argc));

            string[] ret = new string[argc];
            for (int i = 0; i < argc; i++)
            {
                ret[i] = mp.ReadString(i * sizeof(Int32));
            }
            return(ret);
        }
        new public unsafe static int install_keyboard()
        {
            int    ret = AllegroAPI.install_keyboard();
            IntPtr hdl = LoadLibrary(ALLEG_DLL);

            if (hdl != IntPtr.Zero)
            {
                IntPtr addr = GetProcAddress(hdl, "key");
                if (addr != IntPtr.Zero)
                {
                    key      = new Keys();
                    Keys.key = (byte *)addr.ToPointer();
                }
            }
            return(ret);
        }
Exemple #4
0
 public DIALOG(string proc, int x, int y, int w, int h, int fg, int bg, int key, int flags, int d1, int d2, IntPtr dp, IntPtr dp2, IntPtr dp3)
     : this(AllegroAPI.GetAddress(proc), x, y, w, h, fg, bg, key, flags, d1, d2, dp, dp2, dp3)
 {
 }
 public AllegroAPI._DRIVER_INFO[] _midi_drivers()
 {
     return(AllegroAPI.get_drivers(midi_drivers));
 }
 public AllegroAPI._DRIVER_INFO[] _gfx_drivers()
 {
     return(AllegroAPI.get_drivers(gfx_drivers));
 }
 public static void create_color_table(IntPtr table, IntPtr pal, Delegate blend, IntPtr callback)
 {
     AllegroAPI.create_color_table(table, pal, Marshal.GetFunctionPointerForDelegate(blend), callback);
 }
 /// <summary>
 /// Tells if there are keypresses waiting in the input buffer.
 /// </summary>
 new public static bool keypressed()
 {
     return(AllegroAPI.keypressed() != 0);
 }
 new public static bool poll_scroll()
 {
     return(AllegroAPI.poll_scroll() > 0);
 }
 public static void destroy_gfx_mode_list(GFX_MODE_LIST mode_list)
 {
     // Frees the memory allocated by allegro, the GC should take care of managed memory
     AllegroAPI.destroy_gfx_mode_list(mode_list.p);
 }
 new public static int set_gfx_mode(int card, int w, int h, int v_w, int v_h)
 {
     return(AllegroAPI.set_gfx_mode(GFX_AUTODETECT_WINDOWED, w, h, v_w, v_h));
 }
Exemple #12
0
        private void MainLoop()
        {
            bool exit          = false;
            int  oldmouse_x    = -1;
            int  oldmouse_y    = -1;
            bool?lastmousepoll = null;
            bool?thismousepoll = null;
            int  lastkey       = -1;

            do
            {
                AllegroAPI.poll_mouse(); //get mouse data

                if ((AllegroAPI.mouse_b & 1) > 0)
                {
                    thismousepoll = true;
                }
                else if (lastmousepoll.HasValue && lastmousepoll.Value == true)
                {
                    thismousepoll = false;
                }
                else
                {
                    thismousepoll = null;
                }



                if (AllegroAPI.mouse_x != oldmouse_x | Allegro.mouse_y != oldmouse_y)
                {
                    RatCow.Controls.GraphicContext.Instance.Render(AllegroAPI.mouse_x, AllegroAPI.mouse_y, thismousepoll);

                    oldmouse_x = AllegroAPI.mouse_x;
                    oldmouse_y = AllegroAPI.mouse_y;
                }
                else if (thismousepoll.HasValue)
                {
                    RatCow.Controls.GraphicContext.Instance.Render(AllegroAPI.mouse_x, AllegroAPI.mouse_y, thismousepoll);
                }

                lastmousepoll = thismousepoll;

                AllegroAPI.poll_keyboard();

                //read keyboard
                if (AllegroAPI.keypressed() != 0)
                {
                    var mapping = TranslateKey();

                    var k = AllegroAPI.readkey();
                    if (k != -1)
                    {
                        char c = (char)(k & 0xFF);

                        if (mapping == Key.Unmapped)
                        {
                            RatCow.Controls.GraphicContext.Instance.RenderText(c);
                        }
                        else
                        {
                            RatCow.Controls.GraphicContext.Instance.RenderKey(mapping, false, false, false);
                        }
                    }

                    lastkey = k;
                }

                AllegroAPI.vsync();
            }while (!exit);
        }