Esempio n. 1
0
        private static void LoadDriver()
        {
            var assembly   = Assembly.Load("Extended.Kernel.Driver");
            var driverType = assembly.GetType("Extended.KernelDriver");

            var setupMethod = driverType.GetMethod(
                "Setup");

            _setupAction =
                (Func <KernelModules, object?, KernelModules>)setupMethod !.CreateDelegate(
                    typeof(Func <KernelModules, object?, KernelModules>));

            var runMethod = driverType.GetMethod("Run");

            _runAction = (Action)runMethod !.CreateDelegate(typeof(Action));

            var pumpEventsMethod = driverType.GetMethod("PumpEvents");

            _pumpEventsAction = (Action)pumpEventsMethod !.CreateDelegate(typeof(Action));

            var shutdownMethod = driverType.GetMethod("Shutdown");

            _shutdownAction = (Action)shutdownMethod !.CreateDelegate(typeof(Action));

            var property  = driverType.GetProperty("Platform");
            var getMethod = property !.GetGetMethod();

            Platform = (NativePlatform)getMethod.Invoke(null, null);
        }
Esempio n. 2
0
    private static void HandleException(object sender, UnhandledExceptionEventArgs e)
    {
        var errorHeader = "Oops! A fatal error occurred.";

        var errorDetails = "Error Details:\n";

        errorDetails += e.ExceptionObject;

        try
        {
            NativePlatform.ShowMessage(
                true,
                "Fatal Error",
                errorHeader,
                errorDetails
                );
        }
        catch (Exception)
        {
            // In case the entire native library cant be loaded, the above call will fail
            // In those cases, we'll fall back to a super super low level MessageBox call,
            // which really shouldn't fail!
            var message = errorHeader + "\n\n" + errorDetails;
            message += "\n\nNOTE: You can press Ctrl+C to copy the content of this message box to your clipboard.";
            MessageBox(IntPtr.Zero, message, "OpenTemple - Fatal Error", 0x10);
        }
    }
Esempio n. 3
0
 /// <summary>
 /// Tries to detect where Temple of Elemental Evil has been installed on this machine.
 /// </summary>
 public static bool TryFind(out string directory)
 {
     // TODO Just try out some "well known" places it could have been installed
     // These are used as the default location by the Retail installer:
     // C:\Program Files (x86)\Atari\Temple of Elemental Evil
     directory = NativePlatform.FindInstallDirectory();
     return(directory != null);
 }
Esempio n. 4
0
        private static void InitDIContainer()
        {
            var builder  = new ContainerBuilder();
            var platform = NativePlatform.GetNativePlatform();

            platform.Initialization(builder);
            Global.Container = builder.Build();
        }
Esempio n. 5
0
        public override bool FinishedLaunching(
            UIApplication application,
            NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            if (null == this._app)
            {
                var platform = new NativePlatform(this);
                this._app = new TestApp(platform);
            }

            this._app.Start();

            return(base.FinishedLaunching(application, launchOptions));
        }
Esempio n. 6
0
 public NativeSocket(NativePlatform p) {
   platform = p;
   broadcast = false;
   socket = NativePInvoke.CreateSocket();
 }
Esempio n. 7
0
      }
      else {
        NativePInvoke.BroadcastDisable(socket);
      }

      broadcast = value;
    public static void Render()
    {
        // If the queue is empty, we have nothing to report
        if (ErrorReporting.Queue.Count == 0)
        {
            return;
        }

        // Clamp _currentErrorIndex
        _currentErrorIndex = Math.Clamp(_currentErrorIndex, 0, ErrorReporting.Queue.Count - 1);

        var screenSize = ImGui.GetIO().DisplaySize;
        var dialogSize = new Vector2(800, 600);

        ImGui.SetNextWindowSize(dialogSize, ImGuiCond.Appearing);
        ImGui.SetNextWindowPos((screenSize - dialogSize) * 0.5f, ImGuiCond.Appearing);
        ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0.4f, 0.2f, 0.2f, 1.0f));
        if (!ImGui.Begin("Unhandled Errors"))
        {
            ImGui.PopStyleColor();
            return;
        }

        ImGui.PopStyleColor();

        ImGui.SetWindowFontScale(1.5f);
        ImGui.Text("Unhandled Exception");

        ImGui.SetWindowFontScale(1.25f);
        var currentErrorText = ErrorReporting.Queue[_currentErrorIndex].Error.ToString();

        ImGui.TextWrapped(currentErrorText);
        ImGui.SetWindowFontScale(1.0f);

        ImGui.Text($"Error {_currentErrorIndex + 1} of {ErrorReporting.Queue.Count}");

        if (ImGui.Button("Dismiss"))
        {
            ErrorReporting.Queue.RemoveAt(_currentErrorIndex);
            if (_currentErrorIndex >= ErrorReporting.Queue.Count)
            {
                _currentErrorIndex = ErrorReporting.Queue.Count - 1;
            }
        }

        ImGui.SameLine();

        if (ImGui.Button("Dismiss All"))
        {
            ErrorReporting.Queue.Clear();
        }

        ImGui.SameLine();
        ImGui.Spacing();
        ImGui.SameLine();

        // Navigate to the previous error in the queue
        if (_currentErrorIndex > 0)
        {
            if (ImGui.ArrowButton("Prev", ImGuiDir.Left))
            {
                _currentErrorIndex--;
            }
        }
        else
        {
            ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
            ImGui.ArrowButton("Prev", ImGuiDir.Left);
            ImGui.PopStyleVar();
        }

        ImGui.SameLine();
        if (_currentErrorIndex + 1 < ErrorReporting.Queue.Count)
        {
            if (ImGui.ArrowButton("Next", ImGuiDir.Right))
            {
                _currentErrorIndex++;
            }
        }
        else
        {
            ImGui.PushStyleVar(ImGuiStyleVar.Alpha, 0.5f);
            ImGui.ArrowButton("Next", ImGuiDir.Right);
            ImGui.PopStyleVar();
        }

        ImGui.SameLine();
        ImGui.Spacing();
        ImGui.SameLine();
        if (ImGui.Button("Copy to Clipboard"))
        {
            if (Tig.MainWindow is MainWindow nativeMainWindow)
            {
                NativePlatform.SetClipboardText(nativeMainWindow.NativeHandle, currentErrorText);
            }
        }

        ImGui.End(); // Window
    }
    private static void OpenSaveGameFolder()
    {
        var gameFolders = new GameFolders();

        NativePlatform.OpenFolder(gameFolders.SaveFolder);
    }