private void LoadGame(Savegame save) { // Set required gameplay elements currentScriptIndex = save.currentScriptIndex; _scripts[currentScriptIndex].currentLine = save.currentScriptLine; _scripts[currentScriptIndex].currentPositionInLine = 0; _environment = save.currentEnvironment; _environment.currentLanguage = UILanguage.createLanguage(Settings.language); _assets.variables = save.currentVariables; // Start game StopSound(false); StopMusic(false); ClearViewport(false); NewGame(false); // Load environment from save LoadSurroundingsFromEnvironment(_environment); Settings.inGame = true; Settings.allowProgress = true; Settings.afterLoad = true; }
public static UILanguage createLanguage(string languageCode) { UILanguage lang = new UILanguage(); switch (languageCode) { case "EN": lang.initial = "EN"; lang.UI_mainMenu_continue = "Continue"; lang.UI_mainMenu_newGame = "New Game"; lang.UI_mainMenu_loadGame = "Load Game"; lang.UI_mainMenu_options = "Options"; lang.UI_mainMenu_exit = "Exit"; lang.UI_loadMenu_delete = "Delete"; lang.UI_loadMenu_load = "Load"; lang.UI_loadMenu_loadInstructions = "Select slot to load:"; lang.UI_loadMenu_deleteInstructions = "Select slot to delete:"; lang.UI_saveMenu_instructions = "Select slot to save:"; lang.UI_saveMenu_save = "Save"; lang.UI_saveMenu_overwriteInstructions = "Overwrite save slot?"; lang.UI_saveMenu_overwrite = "Overwrite"; lang.UI_returnToMenu_instructions = "Return to main menu?\n(Unsaved progress will be lost)"; lang.UI_returnToMenu_return = "Return"; lang.UI_exitGame_instructions = "Exit game?\n(Unsaved progress will be lost)"; lang.UI_exitGame_exit = "Exit"; lang.UI_gameSavedReport = "Game saved"; lang.UI_emptySlot = "*Empty slot*"; lang.UI_confirm = "Confirm"; lang.UI_back = "Back"; lang.UI_cancel = "Cancel"; lang.UI_options_textSpeed = "Text speed"; lang.UI_options_soundVolume = "Sound volume"; lang.UI_options_musicVolume = "Music volume"; lang.UI_options_colorNames = "Color character names"; lang.UI_options_colorBorders = "Color border lines"; break; case "SI": lang.initial = "SI"; lang.UI_mainMenu_continue = "Nadaljuj"; lang.UI_mainMenu_newGame = "Nova igra"; lang.UI_mainMenu_loadGame = "Naloži igro"; lang.UI_mainMenu_options = "Nastavitve"; lang.UI_mainMenu_exit = "Izhod"; lang.UI_loadMenu_delete = "Izbriši"; lang.UI_loadMenu_load = "Naloži"; lang.UI_loadMenu_loadInstructions = "Izberi prostor za nalaganje:"; lang.UI_loadMenu_deleteInstructions = "Izberi prostor za izbris:"; lang.UI_saveMenu_instructions = "Izberi prostor za shranjevanje:"; lang.UI_saveMenu_save = "Shrani"; lang.UI_saveMenu_overwriteInstructions = "Prepiši shranjeno igro?"; lang.UI_saveMenu_overwrite = "Prepiši"; lang.UI_returnToMenu_instructions = "Vrnitev na glavni meni?\n(Neshranjen napredek bo izgubljen)"; lang.UI_returnToMenu_return = "Vrni"; lang.UI_exitGame_instructions = "Izhod iz igre?\n(Neshranjen napredek bo izgubljen)"; lang.UI_exitGame_exit = "Izhod"; lang.UI_gameSavedReport = "Igra shranjena"; lang.UI_emptySlot = "*Prazno*"; lang.UI_confirm = "Potrdi"; lang.UI_back = "Nazaj"; lang.UI_cancel = "Prekliči"; lang.UI_options_textSpeed = "Hitrost besedila"; lang.UI_options_soundVolume = "Glasnost zvokov"; lang.UI_options_musicVolume = "Glasnost glasbe"; lang.UI_options_colorNames = "Pobarvaj imena likov"; lang.UI_options_colorBorders = "Pobarvaj okvir besedila"; break; } return(lang); }
/* * Loads main menu elements */ private void MainMenu(bool restartBackground, bool restartMusic) { ClearViewport(true); TextBlock gameNameTextBlock = new TextBlock { Name = "gameNameTextBlock", Text = Settings.gameName, FontSize = 48, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.AliceBlue) }; ViewportContainer.Children.Add(gameNameTextBlock); Canvas.SetLeft(gameNameTextBlock, 100); Canvas.SetTop(gameNameTextBlock, 50); Panel.SetZIndex(gameNameTextBlock, 2); Savegame lastSave = FindLastSave(); if (lastSave != null) { Button continueButton = new Button { Name = "continueButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock continueTextBlock = new TextBlock { Name = "continueTextBlock", Text = _environment.currentLanguage.UI_mainMenu_continue, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; continueButton.Content = continueTextBlock; continueButton.Click += (sender, args) => { LoadGame(lastSave); }; ViewportContainer.Children.Add(continueButton); Canvas.SetLeft(continueButton, 100); Canvas.SetTop(continueButton, 200); Panel.SetZIndex(continueButton, 2); } Button newGameButton = new Button { Name = "newGameButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock newGameTextBlock = new TextBlock { Name = "newGameTextBlock", Text = _environment.currentLanguage.UI_mainMenu_newGame, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; newGameButton.Content = newGameTextBlock; newGameButton.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(NewGameButtonClick)); ViewportContainer.Children.Add(newGameButton); Canvas.SetLeft(newGameButton, 100); Canvas.SetTop(newGameButton, 280); Panel.SetZIndex(newGameButton, 2); Button loadGameButton = new Button { Name = "newGameButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock loadGameTextBlock = new TextBlock { Name = "loadGameTextBlock", Text = _environment.currentLanguage.UI_mainMenu_loadGame, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; loadGameButton.Content = loadGameTextBlock; loadGameButton.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(LoadGameButtonClick)); ViewportContainer.Children.Add(loadGameButton); Canvas.SetLeft(loadGameButton, 100); Canvas.SetTop(loadGameButton, 360); Panel.SetZIndex(loadGameButton, 2); Button optionsButton = new Button { Name = "optionsButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock optionsTextBlock = new TextBlock { Name = "optionsTextBlock", Text = _environment.currentLanguage.UI_mainMenu_options, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; optionsButton.Content = optionsTextBlock; optionsButton.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(OptionsButtonClick)); ViewportContainer.Children.Add(optionsButton); Canvas.SetLeft(optionsButton, 100); Canvas.SetTop(optionsButton, 440); Panel.SetZIndex(optionsButton, 2); Button exitButton = new Button { Name = "exitButton", Width = 320, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock exitTextBlock = new TextBlock { Name = "exitTextBlock", Text = _environment.currentLanguage.UI_mainMenu_exit, FontSize = 20, FontWeight = FontWeights.Bold, Foreground = new SolidColorBrush(Colors.White) }; exitButton.Content = exitTextBlock; exitButton.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(ExitButtonClick)); ViewportContainer.Children.Add(exitButton); Canvas.SetLeft(exitButton, 100); Canvas.SetTop(exitButton, 520); Panel.SetZIndex(exitButton, 2); Button languageButton = new Button { Name = "languageButton", Width = 48, Height = 48, Background = new SolidColorBrush(Color.FromArgb(192, 16, 16, 16)) }; TextBlock languageTextBlock = new TextBlock { Name = "languageTextBlock", Text = _environment.currentLanguage.initial, FontSize = 20, FontWeight = FontWeights.ExtraBold, Foreground = new SolidColorBrush(Colors.White) }; languageButton.Content = languageTextBlock; languageButton.Click += (sender, args) => { int langIndex = Settings.LanguageInitialList.FindIndex(s => s == Settings.language); Settings.language = langIndex == Settings.LanguageInitialList.Count - 1 ? Settings.LanguageInitialList[0] : Settings.LanguageInitialList[langIndex + 1]; _environment.currentLanguage = UILanguage.createLanguage(Settings.language); MainMenu(false, false); SaveSettings(); }; ViewportContainer.Children.Add(languageButton); Canvas.SetLeft(languageButton, Settings.windowWidth - 98); Canvas.SetTop(languageButton, Settings.windowHeight - 98); Panel.SetZIndex(languageButton, 2); AllowResize(true); // Menu background image and music if (restartBackground) { ShowBackground("menu_background", 10); } if (restartMusic) { _backgroundMusicPlayer.Stop(); _soundEffectPlayer.Stop(); PlaySound("menu_music", 1, true); } }