예제 #1
0
 public static float DrawOptionListing(Rect rect, List <ListableOption> optList)
 {
     if (optList.Count > 0 && optList[0].GetType() == typeof(ListableOption))
     {
         if (Current.ProgramState == ProgramState.Entry)
         {
             var item = new ListableOption("OCity_LAN_btn".Translate(), delegate
             {
                 OnMainMenuNetClick();
             }, null);
             optList.Insert(0, item);
         }
     }
     return(OptionListingUtility.DrawOptionListing(rect, optList));
 }
예제 #2
0
        public static void DoMainMenuControls(Rect rect, bool anyMapFiles)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = new Rect(0f, 0f, 170f, rect.height);
            Rect rect3 = new Rect(rect2.xMax + 17f, 0f, 145f, rect.height);

            Text.Font = GameFont.Small;
            List <ListableOption> list = new List <ListableOption>();

            if (Current.ProgramState == ProgramState.Entry)
            {
                string label = ("Tutorial".CanTranslate() ? ((string)"Tutorial".Translate()) : ((string)"LearnToPlay".Translate()));
                list.Add(new ListableOption(label, delegate
                {
                    InitLearnToPlay();
                }));
                list.Add(new ListableOption("NewColony".Translate(), delegate
                {
                    Find.WindowStack.Add(new Page_SelectScenario());
                }));
            }
            if (Current.ProgramState == ProgramState.Playing && !Current.Game.Info.permadeathMode)
            {
                list.Add(new ListableOption("Save".Translate(), delegate
                {
                    CloseMainTab();
                    Find.WindowStack.Add(new Dialog_SaveFileList_Save());
                }));
            }
            ListableOption item;

            if (anyMapFiles && (Current.ProgramState != ProgramState.Playing || !Current.Game.Info.permadeathMode))
            {
                item = new ListableOption("LoadGame".Translate(), delegate
                {
                    CloseMainTab();
                    Find.WindowStack.Add(new Dialog_SaveFileList_Load());
                });
                list.Add(item);
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                list.Add(new ListableOption("ReviewScenario".Translate(), delegate
                {
                    Find.WindowStack.Add(new Dialog_MessageBox(Find.Scenario.GetFullInformationText(), null, null, null, null, Find.Scenario.name));
                }));
            }
            item = new ListableOption("Options".Translate(), delegate
            {
                CloseMainTab();
                Find.WindowStack.Add(new Dialog_Options());
            }, "MenuButton-Options");
            list.Add(item);
            if (Current.ProgramState == ProgramState.Entry)
            {
                item = new ListableOption("Mods".Translate(), delegate
                {
                    Find.WindowStack.Add(new Page_ModsConfig());
                });
                list.Add(item);
                if (Prefs.DevMode && LanguageDatabase.activeLanguage == LanguageDatabase.defaultLanguage && LanguageDatabase.activeLanguage.anyError)
                {
                    item = new ListableOption("SaveTranslationReport".Translate(), delegate
                    {
                        LanguageReportGenerator.SaveTranslationReport();
                    });
                    list.Add(item);
                }
                item = new ListableOption("Credits".Translate(), delegate
                {
                    Find.WindowStack.Add(new Screen_Credits());
                });
                list.Add(item);
            }
            if (Current.ProgramState == ProgramState.Playing)
            {
                if (Current.Game.Info.permadeathMode)
                {
                    item = new ListableOption("SaveAndQuitToMainMenu".Translate(), delegate
                    {
                        LongEventHandler.QueueLongEvent(delegate
                        {
                            GameDataSaveLoader.SaveGame(Current.Game.Info.permadeathModeUniqueName);
                            MemoryUtility.ClearAllMapsAndWorld();
                        }, "Entry", "SavingLongEvent", doAsynchronously: false, null, showExtraUIInfo: false);
                    });
                    list.Add(item);
                    item = new ListableOption("SaveAndQuitToOS".Translate(), delegate
                    {
                        LongEventHandler.QueueLongEvent(delegate
                        {
                            GameDataSaveLoader.SaveGame(Current.Game.Info.permadeathModeUniqueName);
                            LongEventHandler.ExecuteWhenFinished(delegate
                            {
                                Root.Shutdown();
                            });
                        }, "SavingLongEvent", doAsynchronously: false, null, showExtraUIInfo: false);
                    });
                    list.Add(item);
                }
                else
                {
                    Action action = delegate
                    {
                        if (GameDataSaveLoader.CurrentGameStateIsValuable)
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmQuit".Translate(), delegate
                            {
                                GenScene.GoToMainMenu();
                            }, destructive: true));
                        }
                        else
                        {
                            GenScene.GoToMainMenu();
                        }
                    };
                    item = new ListableOption("QuitToMainMenu".Translate(), action);
                    list.Add(item);
                    Action action2 = delegate
                    {
                        if (GameDataSaveLoader.CurrentGameStateIsValuable)
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmQuit".Translate(), delegate
                            {
                                Root.Shutdown();
                            }, destructive: true));
                        }
                        else
                        {
                            Root.Shutdown();
                        }
                    };
                    item = new ListableOption("QuitToOS".Translate(), action2);
                    list.Add(item);
                }
            }
            else
            {
                item = new ListableOption("QuitToOS".Translate(), delegate
                {
                    Root.Shutdown();
                });
                list.Add(item);
            }
            OptionListingUtility.DrawOptionListing(rect2, list);
            Text.Font = GameFont.Small;
            List <ListableOption> list2 = new List <ListableOption>();
            ListableOption        item2 = new ListableOption_WebLink("FictionPrimer".Translate(), "https://rimworldgame.com/backstory", TexButton.IconBlog);

            list2.Add(item2);
            item2 = new ListableOption_WebLink("LudeonBlog".Translate(), "https://ludeon.com/blog", TexButton.IconBlog);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("Forums".Translate(), "https://ludeon.com/forums", TexButton.IconForums);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("OfficialWiki".Translate(), "https://rimworldwiki.com", TexButton.IconBlog);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("TynansTwitter".Translate(), "https://twitter.com/TynanSylvester", TexButton.IconTwitter);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("TynansDesignBook".Translate(), "https://tynansylvester.com/book", TexButton.IconBook);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("HelpTranslate".Translate(), TranslationsContributeURL, TexButton.IconForums);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("BuySoundtrack".Translate(), "http://www.lasgameaudio.co.uk/#!store/t04fw", TexButton.IconSoundtrack);
            list2.Add(item2);
            float num = OptionListingUtility.DrawOptionListing(rect3, list2);

            GUI.BeginGroup(rect3);
            if (Current.ProgramState == ProgramState.Entry && Widgets.ButtonText(new Rect(0f, num + 10f, rect3.width, 50f), LanguageDatabase.activeLanguage.FriendlyNameNative))
            {
                List <FloatMenuOption> list3 = new List <FloatMenuOption>();
                foreach (LoadedLanguage allLoadedLanguage in LanguageDatabase.AllLoadedLanguages)
                {
                    LoadedLanguage localLang = allLoadedLanguage;
                    list3.Add(new FloatMenuOption(localLang.DisplayName, delegate
                    {
                        LanguageDatabase.SelectLanguage(localLang);
                        Prefs.Save();
                    }));
                }
                Find.WindowStack.Add(new FloatMenu(list3));
            }
            GUI.EndGroup();
            GUI.EndGroup();
        }
예제 #3
0
 // Stops the button from being drawn if setting is inactive.
 static bool Prefix(ListableOption __instance) => ToggleManager.IsActive(Format(__instance.label, Current.ProgramState));
 public static void DoMainMenuButtons(Rect rect, bool anyWorldFiles, bool anyMapFiles,
     Action backToGameButtonAction = null)
 {
     Text.Font = GameFont.Small;
     var list = new List<ListableOption>();
     ListableOption item;
     // added "continue" and "quick start" buttons
     if (Current.ProgramState == ProgramState.Entry)
     {
         if (anyMapFiles)
         {
             item = new ListableOption("Continue", delegate
             {
                 var latestSavePath =
                     Path.GetFileNameWithoutExtension(GenFilePaths.AllSavedGameFiles?.FirstOrDefault()?.Name);
                 PreLoadUtility.CheckVersionAndLoad(GenFilePaths.FilePathForSavedGame(latestSavePath),
                     ScribeMetaHeaderUtility.ScribeHeaderMode.Map, delegate
                     {
                         Action preLoadLevelAction = delegate
                         {
                             Current.Game = new Game {InitData = new GameInitData {mapToLoad = latestSavePath}};
                         };
                         LongEventHandler.QueueLongEvent(preLoadLevelAction, "Map", "LoadingLongEvent", true,
                             null);
                     });
             });
             list.Add(item);
         }
         if (Prefs.DevMode)
         {
             item = new ListableOption("Quick Start", delegate
             {
                 SceneManager.LoadScene("Map");
             });
             list.Add(item);
         }
     }
     if (Current.ProgramState == ProgramState.Entry)
     {
         list.Add(new ListableOption("NewColony".Translate(), delegate
         {
             Find.WindowStack.Add(new Page_SelectScenario());
         }));
     }
     if (Current.ProgramState == ProgramState.MapPlaying && !Current.Game.Info.permadeathMode)
     {
         list.Add(new ListableOption("Save".Translate(), delegate
         {
             CloseMainTab();
             Find.WindowStack.Add(new Dialog_MapList_Save());
         }));
     }
     if (anyMapFiles && (Current.ProgramState != ProgramState.MapPlaying || !Current.Game.Info.permadeathMode))
     {
         item = new ListableOption("LoadGame".Translate(), delegate
         {
             CloseMainTab();
             Find.WindowStack.Add(new Dialog_MapList_Load());
         });
         list.Add(item);
     }
     if (Current.ProgramState == ProgramState.MapPlaying)
     {
         list.Add(new ListableOption("ReviewScenario".Translate(), delegate
         {
             Find.WindowStack.Add(new Dialog_Message(Find.Scenario.GetFullInformationText(), Find.Scenario.name));
         }));
     }
     item = new ListableOption("Options".Translate(), delegate
     {
         CloseMainTab();
         Find.WindowStack.Add(new Dialog_Options());
     });
     list.Add(item);
     if (Current.ProgramState == ProgramState.Entry)
     {
         item = new ListableOption("Mods".Translate(), delegate
         {
             Find.WindowStack.Add(new Page_ModsConfig());
         });
         list.Add(item);
         item = new ListableOption("Credits".Translate(), delegate
         {
             Find.WindowStack.Add(new Screen_Credits());
         });
         list.Add(item);
     }
     if (Current.ProgramState == ProgramState.MapPlaying)
     {
         if (Current.Game.Info.permadeathMode)
         {
             item = new ListableOption("SaveAndQuitToMainMenu".Translate(), delegate
             {
                 LongEventHandler.QueueLongEvent(delegate
                 {
                     GameDataSaveLoader.SaveGame(Current.Game.Info.permadeathModeUniqueName);
                 }, "Entry", "SavingLongEvent", false, null);
             });
             list.Add(item);
             item = new ListableOption("SaveAndQuitToOS".Translate(), delegate
             {
                 LongEventHandler.QueueLongEvent(delegate
                 {
                     GameDataSaveLoader.SaveGame(Current.Game.Info.permadeathModeUniqueName);
                     LongEventHandler.ExecuteWhenFinished(Root.Shutdown);
                 }, "SavingLongEvent", false, null);
             });
             list.Add(item);
         }
         else
         {
             Action action = delegate
             {
                 if (GameDataSaveLoader.CurrentMapStateIsValuable)
                 {
                     Find.WindowStack.Add(new Dialog_Confirm("ConfirmQuit".Translate(), delegate
                     {
                         SceneManager.LoadScene("Entry");
                     }, true));
                 }
                 else
                 {
                     SceneManager.LoadScene("Entry");
                 }
             };
             item = new ListableOption("QuitToMainMenu".Translate(), action);
             list.Add(item);
             Action action2 = delegate
             {
                 if (GameDataSaveLoader.CurrentMapStateIsValuable)
                 {
                     Find.WindowStack.Add(new Dialog_Confirm("ConfirmQuit".Translate(), Root.Shutdown, true));
                 }
                 else
                 {
                     Root.Shutdown();
                 }
             };
             item = new ListableOption("QuitToOS".Translate(), action2);
             list.Add(item);
         }
     }
     else
     {
         item = new ListableOption("QuitToOS".Translate(), Root.Shutdown);
         list.Add(item);
     }
     OptionListingUtility.DrawOptionListing(rect, list);
 }
예제 #5
0
        public static void Prefix(Rect rect, List <ListableOption> optList)
        {
            //File.WriteAllText(Loger.PathLog + @"optList.txt", DevelopTest.TextObj(optList), Encoding.UTF8);
            if (optList.Count > 0 && optList[0].GetType() == typeof(ListableOption))
            {
                if (Current.ProgramState == ProgramState.Entry)
                {
                    var item = new ListableOption("OCity_LAN_btn".Translate(), delegate
                    {
                        MainMenu.OnMainMenuNetClick();
                    }, null);
                    optList.Insert(0, item);
                }
                else
                {
                    if (SessionClient.Get.IsLogined)
                    {
                        for (int i = 0; i < optList.Count; i++)
                        {
                            if (optList[i].label == "Save".Translate() ||
                                optList[i].label == "LoadGame".Translate() ||
                                optList[i].label == "ReviewScenario".Translate() ||
                                optList[i].label == "SaveAndQuitToMainMenu".Translate() ||
                                optList[i].label == "SaveAndQuitToOS".Translate() ||
                                optList[i].label == "ConfirmQuit".Translate() ||
                                optList[i].label == "QuitToMainMenu".Translate() ||
                                optList[i].label == "QuitToOS".Translate())
                            {
                                optList.RemoveAt(i--);
                            }
                        }
                        var item = new ListableOption("Онлайн".NeedTranslate(), delegate
                        {
                            Dialog_MainOnlineCity.ShowHide();
                        }, null);
                        optList.Add(item);

                        item = new ListableOption("QuitToMainMenu".Translate(), delegate
                        {
                            if (GameExit.BeforeExit != null)
                            {
                                GameExit.BeforeExit();
                            }
                            GenScene.GoToMainMenu();
                        }, null);
                        optList.Add(item);

                        item = new ListableOption("QuitToOS".Translate(), delegate
                        {
                            if (GameExit.BeforeExit != null)
                            {
                                GameExit.BeforeExit();
                            }
                            Root.Shutdown();
                        }, null);
                        optList.Add(item);
                    }
                }
            }

            if (Inited)
            {
                return;
            }
            Inited = true;
            SessionClientController.Init();
        }
예제 #6
0
        public static void Prefix(Rect rect, List <ListableOption> optList)
        {
            if (optList.Count > 0 && optList[0].GetType() == typeof(ListableOption))
            {
                if (Current.ProgramState == ProgramState.Entry)
                {
                    var item = new ListableOption("OCity_LAN_btn".Translate(), delegate
                    {
                        MainMenu.OnMainMenuNetClick();
                    }, null);
                    optList.Insert(0, item);
                }
                else
                {
                    if (SessionClient.Get.IsLogined)
                    {
                        for (int i = 0; i < optList.Count; i++)
                        {
                            if (optList[i].label == "Save".Translate() ||
                                optList[i].label == "LoadGame".Translate() ||
                                optList[i].label == "ReviewScenario".Translate() ||
                                optList[i].label == "SaveAndQuitToMainMenu".Translate() ||
                                optList[i].label == "SaveAndQuitToOS".Translate() ||
                                optList[i].label == "ConfirmQuit".Translate() ||
                                optList[i].label == "QuitToMainMenu".Translate() ||
                                optList[i].label == "QuitToOS".Translate())
                            {
                                optList.RemoveAt(i--);
                            }
                        }
                        var item = new ListableOption("OCity_MainMenu_Online".Translate(), delegate
                        {
                            Dialog_MainOnlineCity.ShowHide();
                        }, null);
                        optList.Add(item);

                        if (SessionClientController.Data.AttackModule != null)
                        {
                            item = new ListableOption("OCity_MainMenu_Withdraw".Translate(), delegate
                            {
                                Loger.Log("Client MainMenu VictoryHost");
                                SessionClientController.Data.AttackModule.VictoryHostToHost = true;
                            }, null);
                            optList.Add(item);
                        }

                        if (SessionClientController.Data.AttackUsModule != null)
                        {
                            item = new ListableOption("OCity_MainMenu_Surrender".Translate(), delegate
                            {
                                Loger.Log("Client MainMenu VictoryAttacker");
                                SessionClientController.Data.AttackUsModule.ConfirmedVictoryAttacker = true;
                            }, null);
                            optList.Add(item);
                        }

                        item = new ListableOption("QuitToMainMenu".Translate(), delegate
                        {
                            if (GameExit.BeforeExit != null)
                            {
                                GameExit.BeforeExit();
                            }
                            GenScene.GoToMainMenu();
                        }, null);
                        optList.Add(item);

                        item = new ListableOption("QuitToOS".Translate(), delegate
                        {
                            if (GameExit.BeforeExit != null)
                            {
                                GameExit.BeforeExit();
                            }
                            Root.Shutdown();
                        }, null);
                        optList.Add(item);
                    }
                }
            }

            if (Inited)
            {
                return;
            }
            Inited = true;
            SessionClientController.Init();
        }
예제 #7
0
        public static void DoMainMenuButtons(Rect rect, bool anyWorldFiles, bool anyMapFiles, Action backToGameButtonAction = null)
        {
            Rect rect2 = new Rect(0f, 0f, 200f, rect.height);
            Rect rect3 = new Rect(rect2.xMax + 17f, 0f, -1f, rect.height);

            rect3.xMax = rect.width;
            Text.Font  = GameFont.Small;
            List <ListableOption> list = new List <ListableOption>();
            ListableOption        item;

            if (Game.Mode == GameMode.Entry)
            {
                item = new ListableOption("CreateWorld".Translate(), delegate
                {
                    MapInitData.Reset();
                    Find.WindowStack.Add(new Page_CreateWorldParams());
                });
                list.Add(item);
                if (anyWorldFiles)
                {
                    item = new ListableOption("NewColony".Translate(), delegate
                    {
                        MapInitData.Reset();
                        Find.WindowStack.Add(new Page_SelectStoryteller());
                    });
                    list.Add(item);
                }
            }
            if (Game.Mode == GameMode.MapPlaying)
            {
                if (backToGameButtonAction != null)
                {
                    item = new ListableOption("BackToGame".Translate(), backToGameButtonAction);
                    list.Add(item);
                }
                item = new ListableOption("Save".Translate(), delegate
                {
                    MainMenuDrawer.CloseMainTab();
                    Find.WindowStack.Add(new Dialog_MapList_Save());
                });
                list.Add(item);
            }
            if (anyMapFiles)
            {
                item = new ListableOption("Load".Translate(), delegate
                {
                    MainMenuDrawer.CloseMainTab();
                    Find.WindowStack.Add(new Dialog_MapList_Load());
                });
                list.Add(item);
            }
            item = new ListableOption("EdB.InterfaceOptions.Button.GameOptions".Translate(), delegate
            {
                MainMenuDrawer.CloseMainTab();
                Find.WindowStack.Add(new Dialog_Options());
            });
            list.Add(item);
            if (Preferences.Instance.AtLeastOne)
            {
                item = new ListableOption("EdB.InterfaceOptions.Button.InterfaceOptions".Translate(), delegate
                {
                    MainMenuDrawer.CloseMainTab();
                    Find.WindowStack.Add(new Dialog_InterfaceOptions());
                });
                list.Add(item);
            }
            if (Game.Mode == GameMode.Entry)
            {
                item = new ListableOption("Mods".Translate(), delegate
                {
                    Find.WindowStack.Add(new Page_ModsConfig());
                });
                list.Add(item);
                item = new ListableOption("Credits".Translate(), delegate
                {
                    Find.WindowStack.Add(new Page_Credits());
                });
                list.Add(item);
            }
            if (Game.Mode == GameMode.MapPlaying)
            {
                Action action = delegate
                {
                    Find.WindowStack.Add(new Dialog_Confirm("ConfirmQuit".Translate(), delegate
                    {
                        Application.LoadLevel("Entry");
                    }, true));
                };
                item = new ListableOption("QuitToMainMenu".Translate(), action);
                list.Add(item);
                Action action2 = delegate
                {
                    Find.WindowStack.Add(new Dialog_Confirm("ConfirmQuit".Translate(), delegate
                    {
                        Root.Shutdown();
                    }, true));
                };
                item = new ListableOption("QuitToOS".Translate(), action2);
                list.Add(item);
            }
            else
            {
                item = new ListableOption("QuitToOS".Translate(), delegate
                {
                    Root.Shutdown();
                });
                list.Add(item);
            }
            Rect rect4 = rect2.ContractedBy(17f);

            OptionListingUtility.DrawOptionListing(rect4, list);
            Text.Font = GameFont.Small;
            List <ListableOption> list2 = new List <ListableOption>();
            ListableOption        item2 = new ListableOption_WebLink("FictionPrimer".Translate(), "https://docs.google.com/document/d/1pIZyKif0bFbBWten4drrm7kfSSfvBoJPgG9-ywfN8j8/pub", MainMenuDrawer.IconBlog);

            list2.Add(item2);
            item2 = new ListableOption_WebLink("LudeonBlog".Translate(), "http://ludeon.com/blog", MainMenuDrawer.IconBlog);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("Forums".Translate(), "http://ludeon.com/forums", MainMenuDrawer.IconForums);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("OfficialWiki".Translate(), "http://rimworldwiki.com", MainMenuDrawer.IconBlog);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("TynansTwitter".Translate(), "https://twitter.com/TynanSylvester", MainMenuDrawer.IconTwitter);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("TynansDesignBook".Translate(), "http://tynansylvester.com/book", MainMenuDrawer.IconBook);
            list2.Add(item2);
            item2 = new ListableOption_WebLink("HelpTranslate".Translate(), "http://ludeon.com/forums/index.php?topic=2933.0", MainMenuDrawer.IconForums);
            list2.Add(item2);
            Rect  rect5 = rect3.ContractedBy(17f);
            float num   = OptionListingUtility.DrawOptionListing(rect5, list2);

            GUI.BeginGroup(rect5);
            if (Game.Mode == GameMode.Entry && Widgets.ImageButton(new Rect(0f, num + 10f, 64f, 32f), LanguageDatabase.activeLanguage.icon))
            {
                List <FloatMenuOption> list3 = new List <FloatMenuOption>();
                foreach (LoadedLanguage current in LanguageDatabase.AllLoadedLanguages)
                {
                    LoadedLanguage localLang = current;
                    list3.Add(new FloatMenuOption(localLang.FriendlyNameNative, delegate
                    {
                        LanguageDatabase.SelectLanguage(localLang);
                        Prefs.Save();
                    }, MenuOptionPriority.Medium, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(list3, false));
            }
            GUI.EndGroup();
        }