Exemplo n.º 1
0
 public static bool OpenExistingAppCallback(IntPtr hWnd, IntPtr lParam)
 {
     if (Win32.GetProp(hWnd, Game.programGuid) != IntPtr.Zero)
     {
         Win32.SetForegroundWindow(hWnd);
         IntPtr intPtr      = IntPtr.Zero;
         int    cbData      = 0;
         string mapArgument = EngineUtils.GetMapArgument();
         if (mapArgument != null)
         {
             intPtr = Marshal.StringToCoTaskMemUni(mapArgument);
             cbData = (mapArgument.Length + 1) * 2;
         }
         if (intPtr != IntPtr.Zero)
         {
             Win32.COPYDATASTRUCT cOPYDATASTRUCT = default(Win32.COPYDATASTRUCT);
             cOPYDATASTRUCT.dwData = IntPtr.Zero;
             cOPYDATASTRUCT.lpData = intPtr;
             cOPYDATASTRUCT.cbData = cbData;
             Win32.SendMessage(hWnd, 74, 0, ref cOPYDATASTRUCT);
         }
         Marshal.FreeCoTaskMem(intPtr);
         return(false);
     }
     return(true);
 }
Exemplo n.º 2
0
        public bool Init(Game game)
        {
            Log.log("Init Game");

            InitInternal();
            string[] commandLineArgs = Environment.GetCommandLineArgs();
            string   text            = " -editorpc -language=";
            string   language        = GetLanguage();

            if (language.Length == 0)
            {
                ResourceManager resourceManager = new ResourceManager("FC3.Properties.Resources", Assembly.GetExecutingAssembly());
                string          @string         = resourceManager.GetString("IDS_ERR_MISSING_REGISTRY_KEY");
                Log.error(@string, "Far Cry 3 Map Editor");
                return(false);
            }
            text += language;
            int num = 1;

            if (EngineUtils.GetMapArgument() != null)
            {
                num = 2;
            }

            Log.log("Init DuniaEngine");
            if (!Binding.InitDuniaEngine(Process.GetCurrentProcess().MainModule.BaseAddress, game.MainForm.Handle, game.MainForm.Viewport.Handle, string.Join(" ", commandLineArgs, num, commandLineArgs.Length - num) + text, true, true, m_delegateMessagePumpCallback))
            {
                return(false);
            }
            // TODO:Pretty Slow do we need?
            //foreach (ProcessModule processModule in Process.GetCurrentProcess().Modules)
            //{
            //	if (processModule.ModuleName.StartsWith("Nomad") || processModule.ModuleName.StartsWith("InGameEditor"))
            //	{
            //		Binding.FCE_Hack_Init(processModule.BaseAddress);
            //	}
            //}

            Log.log("Acquiring Input");
            Binding.FCE_Engine_AutoAcquireInput(true);
            //Editor.Init(); // TODO:Editor Init ? Hooks?
            game.Initialise();

            Binding.FCE_Engine_Reset(game.MainForm.Handle, game.MainForm.Viewport.Handle, m_delegateMessagePumpCallback);
            if (!Directory.Exists(PersonalPath))
            {
                Directory.CreateDirectory(PersonalPath);
            }
            m_initialized = true;
            return(true);
        }