Exemple #1
0
        internal static void UpdateTracker(Graphics g)
        {
            int    i, start_index = pickups_to_show.Length / 2 - (1 - pickups_to_show.Length % 2);
            String IGT           = "";
            Size   windowSize    = ImportsMgr.GetWindowSize(dolphin_window);
            Size   iconsRectSize = CalculateIconsRect(windowSize.Width, windowSize.Height);
            int    imgSize       = Math.Min((int)((iconsRectSize.Width - 10) / pickups_to_show.Length), 52);
            int    x             = (windowSize.Width / 2) - start_index * (imgSize + 5);
            int    y             = (windowSize.Height - iconsRectSize.Height) / 2 + 5;
            Font   IGT_Font      = new Font("Arial", (int)(15.7894735f * (4.0f / 3.0f)));
            Font   Icon_Font     = new Font("Arial", (int)(18.0f * ((float)imgSize / 52.0f)));
            int    h             = CalculateIconYOffset(imgSize, Icon_Font.Height, iconsRectSize.Height);

            if (MetroidPrime.IsIngame())
            {
                if (igt_display_type != IGTDisplayType.None)
                {
                    IGT = MetroidPrime.IGTAsStr(igt_display_type);
                    DrawIGT(g, IGT_Font, windowSize.Width / 2 - (int)g.MeasureString(IGT, IGT_Font).Width / 2, y + imgSize + (int)IGT_Font.Size, IGT);
                }
                if (!MetroidPrime.IsSwitchingState())
                {
                    for (i = 0; i < pickups_to_show.Length; i++)
                    {
                        DrawUpgradeIcon(g, Icon_Font, pickups_to_show[i], x + (int)(((float)i - 1.5f) * (imgSize + 5)), y + h, imgSize);
                    }
                }
            }

            g.Save();
            g.Flush();
        }
Exemple #2
0
        internal static bool Init()
        {
            String window_title = "";

            LoadConfig();
#if WINDOWS
            dolphin = Process.GetProcessesByName("dolphin").FirstOrDefault();
#elif LINUX
            List <IntPtr> childWindows = new List <IntPtr>();
            dolphin = Process.GetProcessesByName("dolphin-emu").FirstOrDefault();
#endif
            if (dolphin == null)
            {
                dolphin = Process.GetProcessesByName("MPR").FirstOrDefault();
            }

            if (dolphin == null)
            {
                return(false);
            }

            Is32BitProcess = dolphin.MainModule.BaseAddress.ToInt64() < UInt32.MaxValue;
            dolphin_window = ImportsMgr.FindWindowByPID(dolphin.Id);
            if (dolphin_window == IntPtr.Zero)
            {
                return(false);
            }

            window_title = ImportsMgr.GetWindowTitle(dolphin_window);
            if (window_title.Count((c) => c == '|') >= 4 && window_title.Count((c) => c == '|') <= 5)
            {
                return(true);
            }

#if LINUX
            if (ImportsMgr.FindChildWindows(dolphin_window, ref childWindows).Length > 0)
            {
                foreach (var childWindow in childWindows)
                {
                    dolphin_window = childWindow;
                    window_title   = ImportsMgr.GetWindowTitle(dolphin_window);
                    if (window_title.Count((c) => c == '|') >= 4 && window_title.Count((c) => c == '|') <= 5)
                    {
                        return(true);
                    }
                }
            }
#endif

            dolphin_window = IntPtr.Zero;
            return(false);
        }
Exemple #3
0
        internal static void Write(long gc_address, Byte[] datas)
        {
            long pc_address = 0;

            if (datas == null)
            {
                return;
            }
            try {
                pc_address = RAMBaseAddr + (gc_address - GCRAMBaseAddr);
                ImportsMgr.WriteProcessMemory(dolphin, pc_address, datas);
            } catch { }
        }
Exemple #4
0
        internal static Byte[] Read(long gc_address, int size)
        {
            long pc_address = 0;

            if (size == 0)
            {
                return(new byte[0]);
            }
            try {
                pc_address = RAMBaseAddr + (gc_address - GCRAMBaseAddr);
                return(ImportsMgr.ReadProcessMemory(dolphin, pc_address, size));
            } catch {
                return(null);
            }
        }
Exemple #5
0
 internal static void UpdateTrackerInfo(Form form)
 {
     if (!MetroidPrime.IsIngame())
     {
         return;
     }
     FormUtils.SetWindowPosition(new Point(0, 0));
     FormUtils.SetWindowSize(ImportsMgr.GetWindowSize(dolphin_window));
     form.Invoke(new Action(() =>
     {
         if (Keyboard.IsKeyDown(Dolphin.refresh_config_key))
         {
             Dolphin.LoadConfig();
         }
     }));
 }
Exemple #6
0
        public static void Close()
        {
            if (mainForm == null)
            {
                throw new Exception("Call FormUtils.Init() first!");
            }

            if (mainForm.InvokeRequired)
            {
                mainForm.Invoke(new Action(() => Close()));
            }
            else
            {
                ImportsMgr.DeInit();
                mainForm.Close();
            }
        }
Exemple #7
0
        internal static bool GameInit()
        {
            long RAMBaseAddr  = 0;
            var  mmap_entries = ImportsMgr.EnumerateVirtualMemorySpaces(dolphin).Where(mmap_entry =>
                                                                                       mmap_entry.Size == 0x2000000 &&
                                                                                       !mmap_entry.IsPrivate &&
                                                                                       mmap_entry.Permissions == (VirtualMemoryPermissions.READ | VirtualMemoryPermissions.WRITE)
                                                                                       ).ToArray();

            foreach (var mmap_entry in mmap_entries)
            {
                RAMBaseAddr = mmap_entry.BaseAddress;
                GCMem.Init(dolphin, RAMBaseAddr);
                if (!IsValidGameCode(GameCode))
                {
                    RAMBaseAddr = 0;
                    GCMem.DeInit();
                    continue;
                }
                break;
            }
            return(RAMBaseAddr != 0);
        }
Exemple #8
0
        internal static void InitTracker(Form form)
        {
            String CurDir          = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
            String config_filename = String.Empty;
            int    i;

            if (MetroidPrime.GetType().BaseType == typeof(Prime.Prime))
            {
                config_filename = "prime.json";
            }
            if (MetroidPrime.GetType().BaseType == typeof(Echoes.Echoes))
            {
                config_filename = "echoes.json";
            }
            if (MetroidPrime.GetType().BaseType == typeof(Corruption.Corruption))
            {
                config_filename = "corruption.json";
            }
            if (config_filename != String.Empty)
            {
                dynamic json = JObject.Parse(File.ReadAllText(CurDir + config_filename));
                try {
                    pickups_to_show = new String[json.pickups.Count];
                    for (i = 0; i < json.pickups.Count; i++)
                    {
                        pickups_to_show[i] = json.pickups[i];
                    }
                    form.Hide();
                    form.FormBorderStyle = FormBorderStyle.None;
                    FormUtils.SetFormBGColor(form.TransparencyKey);
                    form.SetBounds(0, 0, 0, 0, BoundsSpecified.Location);
                    ImportsMgr.AttachWindow(dolphin_window, form.Handle);
                    form.Show();
                } catch { }
            }
        }
Exemple #9
0
 public static void Init(Forms.MainForm form)
 {
     mainForm = form;
     ImportsMgr.Init();
 }