예제 #1
0
        private void InjectButton_Click(object sender, RoutedEventArgs e)
        {
            string rootDir = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "OpenGameCamera", buildVersion ?? "default");

            if (!Directory.Exists(rootDir))
            {
                try
                {
                    Directory.CreateDirectory(rootDir);
                    console.Info("Creating directory for OGC: path=" + rootDir);
                }
                catch (IOException)
                {
                    console.Error("Path already exists as file: path=" + rootDir);
                    return;
                }
                catch (UnauthorizedAccessException)
                {
                    console.Error("Permission error trying to create: path=" + rootDir);
                    return;
                }
            }
            else
            {
                console.Info("Directory already exists at " + rootDir);
            }

            string dllPath = System.IO.Path.Combine(rootDir, "OpenGameCamera.dll");

            if (!File.Exists(dllPath))
            {
                if (!ResourceExtractor.ExtractResourceToFile(console, "OpenGameCamera.OpenGameCamera.dll", dllPath))
                {
                    console.Error("Failed to extract DLL -- if this happens consistently, paste the Log Output in #log-outputs in the OpenGameCamera Discord (https://discord.gg/HZ676Ff)");
                    return;
                }

                console.Info("Extracted OGC to " + dllPath);
            }

            if (!DllInjector.Inject(console, dllPath))
            {
                console.Error("Failed to inject -- if this happens consistently, paste the Log Output in #log-outputs in the OpenGameCamera Discord (https://discord.gg/HZ676Ff)");
                return;
            }

            console.Info("");
        }
예제 #2
0
        public MainWindow()
        {
            InitializeComponent();

            DataContext = console;
            console.SetScrollViewer(Scroller);

            DateTime?buildDate = ResourceExtractor.GetBuildUTCTimestamp(console);

            if (buildDate != null)
            {
                buildTimestampUTC = buildDate.Value;
                buildVersion      = buildDate.Value.ToString("yyyy.MM.dd-HHmmss");

                CheckForLatestRelease();
            }

            console.Info("Welcome to OpenGameCamera. To begin, ensure your game is running before starting OGC.\n\n");
        }