Esempio n. 1
0
        public static IEnumerator Postfix(IEnumerator __result, AddProgramApp __instance, OSProgramDesc desc, bool ___m_dayEnded)
        {
            if (!ConfigHandler.Instance.NoRebootInstallBool.Value)
            {
                yield return(__result);
            }
            ___m_dayEnded = false;
            SFReflect.Run("ShowProgressDialog", __instance, new[] { (object)ScriptLocalization.AddPrograms.INSTALLING, desc });
            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0f, (object)0.9f, (object)(float)((double)desc.m_installTime * 0.4f), (object)true }));

            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0.9f, (object)0.95f, (object)(float)((double)desc.m_installTime * 0.6f), (object)true }));

            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0.95f, (object)1f, (object)1f, (object)false }));

            ComputerSoftware software = __instance.GetComponentInParent <VirtualComputer>().GetComputer().m_software;

            software.m_programs = new List <string>(software.m_programs)
            {
                desc.m_id
            }.ToArray();
            __instance.m_installPopup.SetActive(false);
            var os = __instance.GetComponentInParent <OS>();

            SFLog.log($"Installing {desc.m_uiName} without rebooting...");
            SFReflect.Run("AddProgramIcon", os, Utils.fixArray(desc));
            var m_userDescs = SFReflect.Get <List <OSProgramDesc> >("m_userDescs", os);

            m_userDescs.Add(desc);
            SFReflect.Run("ShowPrograms", __instance);
            SFReflect.Run("BringToFront", os, Utils.fixArray(__instance.GetComponentInParent <WindowFrame>()));
            yield break;
        }
Esempio n. 2
0
        static IEnumerator Postfix(IEnumerator __result, AddProgramApp __instance, OSProgramDesc desc, bool ___m_dayEnded)
        {
            ___m_dayEnded = false;
            ReflectionUtils.Run("ShowProgressDialog", __instance, new object[] { ScriptLocalization.AddPrograms.INSTALLING, desc });
            yield return(ReflectionUtils.Run <IEnumerator>("ShowProgress", __instance, new object[] { 0f, 0.9f, (float)desc.m_installTime * 0.4f, true }));

            yield return(ReflectionUtils.Run <IEnumerator>("ShowProgress", __instance, new object[] { 0.9f, 0.95f, (float)desc.m_installTime * 0.6f, true }));

            yield return(ReflectionUtils.Run <IEnumerator>("ShowProgress", __instance, new object[] { 0.95f, 1f, 1f, false }));

            ComputerSoftware software = __instance.GetComponentInParent <VirtualComputer>().GetComputer().m_software;

            software.m_programs = new List <string>(software.m_programs)
            {
                desc.m_id
            }.ToArray();
            var os = __instance.GetComponentInParent <OS>();

            __instance.m_installPopup.SetActive(false);
            OSLogic.InstanceFor(os).AddProgram(desc.m_id);
            OSLogic.InstanceFor(os).UpdatePrograms();
            ReflectionUtils.Run("UpdateProgramList", __instance);

            yield break;
        }
Esempio n. 3
0
        public static IEnumerator Postfix(IEnumerator __result, AddProgramApp __instance, OSProgramDesc desc, bool ___m_dayEnded)
        {
            if (!ConfigHandler.Instance.NoRebootUnInstallBool.Value)
            {
                yield return(__result);
            }
            ___m_dayEnded = false;
            SFReflect.Run("ShowProgressDialog", __instance, new[] { (object)ScriptLocalization.AddPrograms.REMOVING, desc });
            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0f, (object)0.9f, (object)(float)((double)desc.m_removeTime * 0.2f), (object)true }));

            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0.9f, (object)0.95f, (object)(float)((double)desc.m_removeTime * 0.8f), (object)true }));

            yield return(SFReflect.Run <IEnumerator>("ShowProgress", __instance, new[] { (object)0.95f, (object)1f, (object)1f, (object)false }));

            ComputerSoftware software = __instance.GetComponentInParent <VirtualComputer>().GetComputer().m_software;
            List <string>    list     = new List <string>(software.m_programs);

            list.Remove(desc.m_id);
            software.m_programs = list.ToArray();
            __instance.m_installPopup.SetActive(false);
            var os = __instance.GetComponentInParent <OS>();

            SFLog.log($"Uninstalling {desc.m_uiName} without rebooting...");
            var m_icons = SFReflect.Get <List <ProgramIcon> >("m_icons", os);

            foreach (var icon in m_icons)
            {
                if (icon.m_text.text == desc.m_uiName)
                {
                    m_icons.Remove(icon);
                    UnityEngine.Object.Destroy((UnityEngine.Object)icon.gameObject);
                    break;
                }
            }
            var m_userDescs = SFReflect.Get <List <OSProgramDesc> >("m_userDescs", os);

            foreach (var userDesc in m_userDescs)
            {
                if (userDesc.m_id == desc.m_id)
                {
                    m_userDescs.Remove(userDesc);
                    UnityEngine.Object.Destroy(userDesc);
                    break;
                }
            }
            SFReflect.Run("ShowPrograms", __instance);
            yield break;
        }
Esempio n. 4
0
        static void Postfix(AddProgramApp __instance)
        {
            foreach (object o in __instance.m_programList.content)
            {
                UnityEngine.Object.Destroy(((Transform)o).gameObject);
            }

            ComputerSave computer           = __instance.GetComponentInParent <VirtualComputer>().GetComputer();
            bool         isUsbDriveInserted = computer.IsUSBDriveInserted();

            if (!isUsbDriveInserted)
            {
                WorkStation componentInParent = __instance.GetComponentInParent <WorkStation>();
                if (componentInParent && componentInParent.m_slot && componentInParent.m_slot.m_type == BenchSlot.Type.SHOP_COMPUTER)
                {
                    isUsbDriveInserted = true;
                }
            }
            if (AddProgramAppLogic.InstanceFor(__instance).addMode == 1)
            {
                if (!isUsbDriveInserted)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.INSERT_USB });
                    return;
                }

                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (CareerStatus.Get().IsProgramAvailableForInstall(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.GetComponentInParent <OS>().Launch(prog);
                        });
                    }
                }
                return;
            }
            if (AddProgramAppLogic.InstanceFor(__instance).addMode == 2)
            {
                if (!isUsbDriveInserted)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.INSERT_USB });
                    return;
                }
                bool programsMissing = false;

                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (!computer.m_software.m_programs.Contains(prog.m_id) && CareerStatus.Get().IsProgramAvailableForInstall(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.StartCoroutine(ReflectionUtils.Run <IEnumerator>("Install", __instance, new object[] { prog }));
                        });
                        programsMissing = true;
                    }
                }

                if (!programsMissing)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.ALL_INSTALLED });
                    return;
                }
            }
            else if (AddProgramAppLogic.InstanceFor(__instance).addMode == 3)
            {
                bool uninstallablePrograms = false;
                foreach (OSProgramDesc prog in PartsDatabase.GetAllPrograms())
                {
                    if (prog.m_canBeUninstalled && computer.m_software.m_programs.Contains(prog.m_id))
                    {
                        UnityEngine.Object.Instantiate <ProgramIcon>(__instance.programIconPrefab, __instance.m_programList.content).Init(prog, false, delegate
                        {
                            __instance.StartCoroutine(ReflectionUtils.Run <IEnumerator>("Uninstall", __instance, new object[] { prog }));
                        });
                        uninstallablePrograms = true;
                    }
                }
                if (!uninstallablePrograms)
                {
                    ReflectionUtils.Run("SetMessage", __instance, new object[] { ScriptLocalization.AddPrograms.NONE_INSTALLED });
                }
            }
        }