Beispiel #1
0
        void InitializeGui(string langFileName)
        {
            if (!Localization.TryLoadFromFile(langFileName, out Exception ex))
            {
                MessageBox.Show($"Error: {ex.Message}", langFileName);
                Environment.Exit(1);
            }

            LanguageChangedMessage                    = "Message_LangChanged".Translate();
            инцидентыToolStripMenuItem.Text           = "Menu_Incidents".Translate();
            pawnHediffsToolStripMenuItem.Text         = "Menu_PawnHediffs".Translate();
            отображениеКолонокToolStripMenuItem.Text  = "Menu_VisibleColumns".Translate();
            скрытьПустыеСтолбцыToolStripMenuItem.Text = "Menu_HideNullColumns".Translate();
            корзинаToolStripMenuItem.Text             = toolStripMenuItem1.Text = "Menu_Cart".Translate();
            добавитьВКорзинуToolStripMenuItem.Text    = "Menu_AddInCart".Translate();
            удалитьИзКорзиныToolStripMenuItem.Text    = "Menu_RemoveFromCart".Translate();
            очиститьКорзинуToolStripMenuItem.Text     = "Menu_ClearCart".Translate();
            языкToolStripMenuItem.Text                = "Menu_Language".Translate();
            exportToolStripMenuItem.Text              = "Menu_Export".Translate();
            exportTabToolStripMenuItem.Text           = "Menu_ExportTab".Translate();
            exportAllTabsToolStripMenuItem.Text       = "Menu_ExportAllTabs".Translate();
            injectDllAndRunToolStripMenuItem.Text     = "Menu_InjectDllAndRun".Translate();

            new ToolTip().SetToolTip(btnResetCache, "Button_ClearTabsCache_Tooltip".Translate());

            ColumnFilter.btnAllText     = "Button_All".Translate();
            ColumnFilter.btnNothingText = "Button_Nothing".Translate();

            button2.Text = "Button_OpenFilterForm".Translate();

            var tabs = cbTabs.Items;

            // Materials
            tabs.Add(new RimHelper.TabControl <Material>("Tab_Materials".Translate(), () =>
                                                         IPC.StateCallback(State.GetMaterials, () => IPC.GetObjectBuf <List <Material> >()),
                                                         dgv, comboBox1, textBox4, pictureBox1));

            // WeaponsRanged
            tabs.Add(new RimHelper.TabControl <WeaponRanged>("Tab_WeaponsRanged".Translate(), () =>
                                                             IPC.StateCallback(State.GetWeaponsRanged, () => IPC.GetObjectBuf <List <WeaponRanged> >()),
                                                             dgv, comboBox1, textBox4, pictureBox1));

            // WeaponsMelee
            tabs.Add(new RimHelper.TabControl <WeaponMelee>("Tab_WeaponsMelee".Translate(), () =>
                                                            IPC.StateCallback(State.GetWeaponsMelee, () => IPC.GetObjectBuf <List <WeaponMelee> >()),
                                                            dgv, comboBox1, textBox4, pictureBox1));

            // Apparels
            tabs.Add(new RimHelper.TabApparel("Tab_Apparel".Translate(), () =>
                                              IPC.StateCallback(State.GetApparels, () => IPC.GetObjectBuf <List <Apparel> >()),
                                              dgv, comboBox1, textBox4, pictureBox1));

            // Buildings From Materials
            tabs.Add(new RimHelper.TabControl <BuildingsFromMaterial>("Tab_BuildingsFromMaterial".Translate(), () =>
                                                                      IPC.StateCallback(State.GetBuildingsFromMaterials,
                                                                                        () => IPC.GetObjectBuf <List <BuildingsFromMaterial> >()),
                                                                      dgv, comboBox1, textBox4, pictureBox1));

            // Animals
            tabs.Add(new RimHelper.TabControl <Animal>("Tab_Animals".Translate(), () =>
                                                       IPC.StateCallback(State.GetAnimals, () => IPC.GetObjectBuf <List <Animal> >()),
                                                       dgv, comboBox1, textBox4, pictureBox1));

            // Debuffs
            tabs.Add(new RimHelper.TabControl <Debuff>("Tab_Debuffs".Translate(), () =>
                                                       IPC.StateCallback(State.GetDebuffs, () => IPC.GetObjectBuf <List <Debuff> >()),
                                                       dgv, comboBox1, textBox4, pictureBox1));

            // Drugs
            tabs.Add(new RimHelper.TabControl <Drug>("Tab_Drugs".Translate(), () =>
                                                     IPC.StateCallback(State.GetDrugs, () => IPC.GetObjectBuf <List <Drug> >()),
                                                     dgv, comboBox1, textBox4, pictureBox1));

            // Foods
            tabs.Add(new RimHelper.TabControl <Food>("Tab_Foods".Translate(), () =>
                                                     IPC.StateCallback(State.GetFoods, () => IPC.GetObjectBuf <List <Food> >()),
                                                     dgv, comboBox1, textBox4, pictureBox1));

            // BodyParts
            tabs.Add(new RimHelper.TabControl <BodyPart>("Tab_BodyParts".Translate(), () =>
                                                         IPC.StateCallback(State.GetBodyParts, () => IPC.GetObjectBuf <List <BodyPart> >()),
                                                         dgv, comboBox1, textBox4, pictureBox1));

            // Facilities
            tabs.Add(new RimHelper.TabControl <Facility>("Tab_Facilities".Translate(), () =>
                                                         IPC.StateCallback(State.GetFacilities, () => IPC.GetObjectBuf <List <Facility> >()),
                                                         dgv, comboBox1, textBox4, pictureBox1));

            // Plants
            tabs.Add(new RimHelper.TabControl <Plant>("Tab_Plant".Translate(), () =>
                                                      IPC.StateCallback(State.GetPlants, () => IPC.GetObjectBuf <List <Plant> >()),
                                                      dgv, comboBox1, textBox4, pictureBox1));

            // Backstorys
            tabs.Add(new RimHelper.TabControl <Backstory>("Tab_Backstorys".Translate(), () =>
                                                          IPC.StateCallback(State.GetBackstorys, () => IPC.GetObjectBuf <List <Backstory> >()),
                                                          dgv, comboBox1, textBox4, pictureBox1));

            // Traits
            tabs.Add(new RimHelper.TabControl <Trait>("Tab_Traits".Translate(), () =>
                                                      IPC.StateCallback(State.GetTraits, () => IPC.GetObjectBuf <List <Trait> >()),
                                                      dgv, comboBox1, textBox4, pictureBox1));

            // CEAmmos
            tabs.Add(new RimHelper.TabControl <CEAmmo>("Tab_CEAmmos".Translate(), () =>
                                                       IPC.StateCallback(State.GetCEAmmos, () => IPC.GetObjectBuf <List <CEAmmo> >()),
                                                       dgv, comboBox1, textBox4, pictureBox1));

            // Tools
            tabs.Add(new RimHelper.TabControl <ST_Tool>("Tab_Tools".Translate(), () =>
                                                        IPC.StateCallback(State.GetTools, () => IPC.GetObjectBuf <List <ST_Tool> >()),
                                                        dgv, comboBox1, textBox4, pictureBox1));

            Localization.LoadColumns();
            Localization.Finalize();
        }
        public static void HandleMessagesTick()
        {
            if (IPC.Active)
            {
                try
                {
                    switch ((State)IPC.State)
                    {
                    case State.Idle:
                        return;

                    case State.GetMaterials:
                        IPC.SetObjectBuf(Materials.Get());
                        break;

                    case State.GetWeaponsRanged:
                        IPC.SetObjectBuf(WeaponsRanged.Get());
                        break;

                    case State.GetWeaponsMelee:
                        IPC.SetObjectBuf(WeaponsMelee.Get());
                        break;

                    case State.GetApparels:
                        IPC.SetObjectBuf(Apparels.Get());
                        break;

                    case State.GetBuildingsFromMaterials:
                        IPC.SetObjectBuf(BuildingsFromMaterials.Get());
                        break;

                    case State.GetAnimals:
                        IPC.SetObjectBuf(Animals.Get());
                        break;

                    case State.GetDebuffs:
                        IPC.SetObjectBuf(Debuffs.Get());
                        break;

                    case State.GetDrugs:
                        IPC.SetObjectBuf(Drugs.Get());
                        break;

                    case State.GetFoods:
                        IPC.SetObjectBuf(Foods.Get());
                        break;

                    case State.GetActiveIncidents:
                        IPC.StringBuf = ActiveIncidents.Get();
                        break;

                    case State.GetPawnsHeddifs:
                        IPC.StringBuf = PawnsHeddifs.Get();
                        break;

                    case State.GetBodyParts:
                        IPC.SetObjectBuf(BodyParts.Get());
                        break;

                    case State.GetFacilities:
                        IPC.SetObjectBuf(Facilities.Get());
                        break;

                    case State.GetPlants:
                        IPC.SetObjectBuf(Plants.Get());
                        break;

                    case State.GetBackstorys:
                        IPC.SetObjectBuf(Backstorys.Get());
                        break;

                    case State.GetTraits:
                        IPC.SetObjectBuf(Traits.Get());
                        break;

                    case State.GetCEAmmos:
                        IPC.SetObjectBuf(CEAmmos.Get());
                        break;

                    case State.GetTools:
                        IPC.SetObjectBuf(Tools.Get());
                        break;

                    case State.BuildingStuffDump:
                        new BuildingStuffDump();
                        break;

                    case State.WeaponApparelDump:
                        IPC.StringBuf = WeaponApparelDump.Get();
                        break;

                    case State.InjectDll:
                        IPC.StringBuf = InjectDll.GetResult(IPC.GetObjectBuf <InjectParameters>());
                        break;

                    case State.GcCollect:
                        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
                        GC.WaitForPendingFinalizers();
                        Log.Warning($"[RimHelperProxy] GC.Collect() called!");
                        break;


                    default:
                        throw new Exception($"UnknownState: {IPC.State}");
                    }
                }
                catch (Exception e)
                {
                    Log.Error($"[HandleMessagesTick] Exception: {e.Message}");
                    Log.Error($"[HandleMessagesTick] StackTrace: {e.StackTrace}");
                }
                finally
                {
                    IPC.State = (int)State.Idle;
                }
            }
        }