private void button1_Click(object sender, EventArgs e) { SaveFileDialog saveCharacter = new SaveFileDialog(); if (TBAGW.Game1.bIsDebug) { saveCharacter.Filter = "Character file|*.cgbcc"; saveCharacter.InitialDirectory = TBAGW.Game1.rootTBAGW; } else { saveCharacter.Filter = "Character file|*.cgbc"; saveCharacter.InitialDirectory = TBAGW.Game1.rootContentExtra; } saveCharacter.Title = "save character"; DialogResult dia = saveCharacter.ShowDialog(); if (DialogResult.OK == dia && saveCharacter.FileName.Contains(saveCharacter.InitialDirectory)) { String fi = saveCharacter.FileName; EditorFileWriter.BasicSpriteWriter(fi, character); Hide(); } else if (System.Windows.Forms.DialogResult.Cancel == dia) { System.Windows.Forms.MessageBox.Show("Cancelled, returning to Editor."); } else if (!saveCharacter.FileName.Contains(saveCharacter.InitialDirectory)) { System.Windows.Forms.MessageBox.Show("Save within mods folder please."); } }
private void button4_Click(object sender, EventArgs e) { if (selectedBGI != null) { EditorFileWriter.BGWriter(selectedBGI, Path.Combine(TBAGW.Game1.rootContent, currentContentFolder, selectedBGI.songCollectionName)); } }
private void GenerateTabs() { List <PlayerSaveData> saves = saveDatas; saves = saves.Distinct().ToList(); saves = saves.OrderBy(psd => psd.timeIndex).ToList(); saves.Reverse(); if (saves.Count != 0 && gcdbSaveData == null) { if (func == null) { gcdbSaveData = EditorFileWriter.gcdbReader(saves[0].databaseLoc); } else if (saves.Count > 1) { gcdbSaveData = EditorFileWriter.gcdbReader(saves[1].databaseLoc); } } for (int i = 0; i < saves.Count; i++) { lfTabs.Add(new LoadFileTab(saves[i], saves, bgPosition, gcdbSaveData)); } }
static public void OverwriteSave(String fn) { PlayerSaveData tempPSD = new PlayerSaveData(); tempPSD.GenerateSave(); EditorFileWriter.OverwriteSaveFileWriter(tempPSD, fn); }
static public void AttemptSave() { PlayerSaveData tempPSD = new PlayerSaveData(); tempPSD.GenerateSave(); EditorFileWriter.SaveFileWriter(tempPSD); }
internal static void QuickSave() { PlayerSaveData tempPSD = new PlayerSaveData(); tempPSD.GenerateSave(); tempPSD.bAutoSave = true; EditorFileWriter.SaveFileWriter(tempPSD); }
private void button8_Click(object sender, EventArgs e) { FolderBrowserDialog folderChoice = new FolderBrowserDialog(); folderChoice.Description = "Please select folder where to load SFX's from!"; bool bDone = false; while (!bDone) { folderChoice.SelectedPath = TBAGW.Game1.rootContent; if (folderChoice.ShowDialog() == DialogResult.OK) { if (folderChoice.SelectedPath.StartsWith(TBAGW.Game1.rootContent)) { currentContentFolder = folderChoice.SelectedPath.Replace(TBAGW.Game1.rootContent, ""); bDone = true; } } } String completePath = Path.Combine(TBAGW.Game1.rootContent, currentContentFolder); if (TBAGW.Game1.bIsDebug) { String[] files = Directory.GetFiles(completePath, "*.cgsfxc", SearchOption.AllDirectories); foreach (var item in files) { try { sfxs.Add(EditorFileWriter.SFXReader(item)); } catch (Exception) { Console.WriteLine("Error reading file: " + item); } } } else { String[] files = Directory.GetFiles(completePath, "*.cgsfx", SearchOption.AllDirectories); foreach (var item in files) { try { sfxs.Add(EditorFileWriter.SFXReader(item)); } catch (Exception) { Console.WriteLine("Error reading file: " + item); } } } }
private void button2_Click(object sender, EventArgs e) { if (listBox1.SelectedIndex != -1) { try { String uriDir = uri + listBox1.SelectedItem.ToString() + @"/"; var list = new List <string>(); // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create(uriDir); request.Method = WebRequestMethods.Ftp.ListDirectory; // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential("Admin", "Bubbi100"); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream); List <string> files = new List <string>(); string line = reader.ReadLine(); while (!string.IsNullOrEmpty(line)) { files.Add(line); line = reader.ReadLine(); } Console.WriteLine("Directory List Complete, status: {0}", response.StatusDescription); reader.Close(); response.Close(); List <String> finalDLlocs = new List <string>(); foreach (var item in files) { finalDLlocs.Add(AttemptDownload(uriDir, item)); } var map = EditorFileWriter.MapReader(finalDLlocs.Find(loc => loc.EndsWith(".cgmapc", StringComparison.OrdinalIgnoreCase))); richTextBox1.Text = "Succesfully loaded the map :'" + finalDLlocs.Find(loc => loc.EndsWith(".cgmapc", StringComparison.OrdinalIgnoreCase)) + "'"; } catch (Exception) { } } }
static internal List <PlayerSaveData> saveFilesIn(String loc) { var watch = System.Diagnostics.Stopwatch.StartNew(); List <PlayerSaveData> saves = new List <PlayerSaveData>(); List <Task <PlayerSaveData> > aSyncReadList = new List <Task <PlayerSaveData> >(); DirectoryInfo info = new DirectoryInfo(loc); var files = info.GetFiles("*.sfc").OrderBy(p => p.CreationTime).ToList(); files.Reverse(); List <String> tempList = new List <string>(); for (int i = 0; i < files.Count; i++) { if (files[i].FullName.EndsWith(".sfc")) { tempList.Add(files[i].FullName); } } for (int i = 0; i < tempList.Count; i++) { int temp = i; aSyncReadList.Add(Task <PlayerSaveData> .Factory.StartNew(() => EditorFileWriter.SaveFileReaderSpawn(tempList[temp]))); // saves.Add(EditorFileWriter.SaveFileReader(tempList[i])); } while (tempList.Count != 0 && aSyncReadList.FindAll(t => t.IsCompleted).Count == tempList.Count) { } aSyncReadList.ForEach(t => saves.Add(t.Result)); watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; Console.WriteLine("Time elapsed : " + elapsedMs); return(saves); }
private void button1_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "XML files (*.xml) | *.xml;"; if (ofd.ShowDialog() == DialogResult.OK) { seoColl = EditorFileWriter.TileSheetProcessor(ofd.FileName); } Console.WriteLine("Tiles: " + seoColl.lseo.FindAll(s => s.spriteObjectType == SpriteExportObject.spriteType.Tile).Count + ", Objects: " + seoColl.lseo.FindAll(s => s.spriteObjectType == SpriteExportObject.spriteType.Object).Count); if (seoColl != null) { label2.Text = "OK."; label3.Text = ofd.FileName; } else { label2.Text = "NOT OK."; } }
public static void Start() { BasicSpriteSelector = new System.Windows.Forms.OpenFileDialog(); bRunFileSelector = true; BasicSpriteSelector.InitialDirectory = Environment.CurrentDirectory; BasicSpriteSelector.Filter = "CGBS Files (.cgbs)|*.cgbs"; BasicSpriteSelector.FilterIndex = 1; BasicSpriteSelector.Multiselect = false; System.Windows.Forms.DialogResult testDia = BasicSpriteSelector.ShowDialog(); if (testDia == System.Windows.Forms.DialogResult.OK) { Console.WriteLine("You selected: " + BasicSpriteSelector.FileName); BaseSprite test = EditorFileWriter.BasicSpriteReader(BasicSpriteSelector.FileName); MapBuilder.testSprite = test; bRunFileSelector = false; } }
static public void Start(Game game) { game.IsMouseVisible = true; textWindowBG = game.Content.Load <Texture2D>(@"Editor\Scripts\TextWindowBG"); textWindowFont = game.Content.Load <SpriteFont>(@"Editor\Scripts\TextWindowFont"); try { scriptObject = EditorFileWriter.ScriptObjectReader(Environment.CurrentDirectory + @"\Scripts\" + 1001 + ".cgScript"); inputText = scriptObject.script.scriptContent[scriptObject.script.scriptContent.Count - 1]; currentLineInScript = scriptObject.script.scriptContent.Count - 1; } catch (Exception) { Console.WriteLine("Error loading script"); scriptObject = new ScriptTestObject(1001); scriptObject.script.scriptContent.Add(inputText); currentLineInScript = 0; } }
private void button11_Click(object sender, EventArgs e) { if (currentContentFolder.Equals("")) { MessageBox.Show("Please, first select the soundpool engine file (the '.cgbgi' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.cgbgic"; } else { openBG.Filter = "Sound engine file|*.cgbgi"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent)) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } } } else { MessageBox.Show("Please, first select the soundpool engine file (the '.cgbgi' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.cgbgic"; } else { openBG.Filter = "Sound engine file|*.cgbgi"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent)) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } } } if (!MapBuilder.parentMap.soundPools.Contains(selectedBGI)) { MapBuilder.parentMap.soundPools.Add(selectedBGI); listBox3.Items.Add(selectedBGI); } }
private void button1_Click(object sender, EventArgs e) { if (currentContentFolder.Equals("")) { MessageBox.Show("Please, first select the soundpool engine file (the '.cgbgi' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.cgbgic"; } else { openBG.Filter = "Sound engine file|*.cgbgi"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent)) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } } } else { MessageBox.Show("Please, first select the soundpool engine file (the '.cgbgi' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.cgbgic"; } else { openBG.Filter = "Sound engine file|*.cgbgi"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent)) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { selectedBGI = EditorFileWriter.BGReader(openBG.FileName); } else if (DialogResult.Cancel == dia) { } } } textBox1.Text = selectedBGI.songCollectionName; numericUpDown1.Value = selectedBGI.songCollectionID; listBox1.Items.Clear(); listBox1.SelectedIndex = -1; foreach (var item in selectedBGI.songNames) { listBox1.Items.Add(item); } }
private void button9_Click(object sender, EventArgs e) { String engineLoc = ""; String sbLoc = ""; String wbLoc = ""; { MessageBox.Show("Please, first select the soundpool engine file (the '.xgs' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.xgs"; } else { openBG.Filter = "Sound engine file|*.xgs"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { engineLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra)) { engineLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } } } { MessageBox.Show("Please, first select the soundbank engine file (the '.xsb' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.xsb"; } else { openBG.Filter = "Sound engine file|*.xsb"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { sbLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra)) { sbLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } } } { MessageBox.Show("Please, first select the WaveBank engine file (the '.xwb' file)."); OpenFileDialog openBG = new OpenFileDialog(); openBG.InitialDirectory = currentContentFolder; if (TBAGW.Game1.bIsDebug) { openBG.Filter = "Sound engine file|*.xwb"; } else { openBG.Filter = "Sound engine file|*.xwb"; } openBG.Title = "Load Sound File"; if (TBAGW.Game1.bIsDebug) { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContent) && !openBG.FileName.Contains(TBAGW.Game1.rootContent + @"Sounds")) { wbLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } else { Console.WriteLine("Cheater"); } } else { DialogResult dia = openBG.ShowDialog(); if (DialogResult.OK == dia && openBG.FileName.Contains(TBAGW.Game1.rootContentExtra)) { wbLoc = openBG.FileName.Replace(TBAGW.Game1.rootContent, ""); } else if (DialogResult.Cancel == dia) { } } } if (!engineLoc.Equals("") && !sbLoc.Equals("") && !wbLoc.Equals("")) { BGInfo tempBGI = new BGInfo(); tempBGI.songELoc = engineLoc; tempBGI.songSBLoc = sbLoc; tempBGI.songWBLoc = wbLoc; tempBGI.songCollectionName = engineLoc; selectedBGI = tempBGI; EditorFileWriter.BGWriter(tempBGI, Path.Combine(TBAGW.Game1.rootContent, currentContentFolder, tempBGI.songCollectionName)); listBox1.Items.Clear(); listBox1.SelectedIndex = -1; foreach (var item in tempBGI.songNames) { listBox1.Items.Add(item); } } }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Console.WriteLine(SteamFriends.GetPersonaName()); base.Initialize(); initiateActions(); ResolutionUtility.bMouseIsVisible = this.IsMouseVisible; hitboxHelp = Content.Load <Texture2D>(@"Graphics\HitBoxHelp"); selectionTexture = Content.Load <Texture2D>(@"Graphics\MainMenu\TestRectangle"); mapBorderHelp = Content.Load <Texture2D>(@"Graphics\Tiles\Basic\BorderTest"); WhiteTex = Content.Load <Texture2D>(@"White"); scenes.Insert((int)(Screens.MainMenu), new MainMenu()); scenes.Insert((int)(Screens.MainGameStart), new NewGameScene()); scenes.Insert((int)(Screens.MainGameContinue), new ContinueGameScene()); scenes.Insert((int)(Screens.OWGame), new OWGame()); scenes.Insert((int)(Screens.BGame), new MainGame()); scenes.Insert((int)(Screens.Options), new Options()); scenes.Insert((int)(Screens.ExitGame), new Scene()); scenes.Insert((int)(Screens.Editor), new Editor()); CursorUtility.Initialize(this); MainGUI.Initialize(this); if (!bRunEditMode) { scenes[SceneUtility.currentScene].Initialize(this); } graphics.PreferMultiSampling = true; graphics.PreferredBackBufferWidth = this.GraphicsDevice.DisplayMode.Width; graphics.PreferredBackBufferHeight = this.GraphicsDevice.DisplayMode.Height; // this.Window.Position = new Point(100, 100); //graphics.IsFullScreen = true; this.IsMouseVisible = false; graphics.ApplyChanges(); LoadAssets(); this.Window.AllowUserResizing = false; //Window.IsBorderless = true; Window.AllowAltF4 = true; //Window.Location = Point.Zero; //900,506 ResolutionUtility.WindowSizeBeforeFullScreen = new Vector2(1366, 768); ResolutionUtility.AdjustResolution(1366, 768, graphics); gameRender = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); gameRender = new RenderTarget2D(GraphicsDevice, 1366, 768); UIRender = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight); monitorSize = new Vector2(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); Console.WriteLine("Primary Monitor Size: " + monitorSize); EditorFileWriter.LoadSaveSettings(); startScreen = new StartScreen(); #if !DEBUG // GameProcessor.Launch(); #endif // GameProcessor.Launch(); }
//Texture2D shapeTexture, Texture2D hitboxTexture, Rectangle spriteGameSize, Rectangle hitBoxTexBox, Rectangle rectangleToDraw static public void Start() { spriteGameSize = rectangleToDraw; BaseSprite testSprite = new BaseSprite(shapeTexture, hitboxTexture, spriteGameSize, hitBoxTexBox, rectangleToDraw, 1, Vector2.Zero); if (Game1.bIsDebug) { spriteSave.Filter = "CG BaseSprite|*.cgbsc"; spriteSave.Title = "Save a Sprite File"; spriteSave.InitialDirectory = Game1.rootTBAGW; System.Windows.Forms.DialogResult dia = spriteSave.ShowDialog(); if (System.Windows.Forms.DialogResult.OK == dia && spriteSave.FileName.Contains(Game1.rootTBAGW)) { EditorFileWriter.BasicSpriteWriter(spriteSave.FileName, testSprite); } else if (System.Windows.Forms.DialogResult.Cancel == dia) { System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Leave the Sprite unsaved?", "WARNING", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Editor.currentEditor = (int)Editor.EditorsCollection.MapEditor; System.Windows.Forms.MessageBox.Show("Cancelled, returning to MapEditor."); } else if (dialogResult == System.Windows.Forms.DialogResult.No) { Start(); } } else { System.Windows.Forms.MessageBox.Show("Select a folder within TBAGW"); Start(); } } else { spriteSave.Filter = "CG BaseSprite|*.cgbs"; spriteSave.Title = "Save a Sprite File"; spriteSave.InitialDirectory = Game1.rootContentExtra; System.Windows.Forms.DialogResult dia = spriteSave.ShowDialog(); if (System.Windows.Forms.DialogResult.OK == dia && spriteSave.FileName.Contains(Game1.rootContentExtra)) { EditorFileWriter.BasicSpriteWriter(spriteSave.FileName, testSprite); } else if (System.Windows.Forms.DialogResult.Cancel == dia) { System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Leave the Sprite unsaved?", "WARNING", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { Editor.currentEditor = (int)Editor.EditorsCollection.MapEditor; System.Windows.Forms.MessageBox.Show("Cancelled, returning to MapEditor."); } else if (dialogResult == System.Windows.Forms.DialogResult.No) { Start(); } } else { System.Windows.Forms.MessageBox.Show("Select a folder within Content Mods"); Start(); } } System.Windows.Forms.MessageBox.Show("Sprite created, returning to map editor"); SpriteEditor.currentScene = (int)SpriteEditor.SpriteEditorScenes.SpriteEditor; Editor.currentEditor = (int)Editor.EditorsCollection.MapEditor; }
static public void Update(GameTime gameTime, Game1 game) { if (Keyboard.GetState().IsKeyDown(Keys.NumPad9) && !KeyboardMouseUtility.AnyButtonsPressed()) { bEnableInput = true; } if (!game.IsMouseVisible) { game.IsMouseVisible = true; } #region testScriptButton if (!bEnableInput) { if (testScriptButton.Contains(Mouse.GetState().Position) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (Mouse.GetState().LeftButton == ButtonState.Pressed) { bTestScript = true; } } } if (bTestScript) { Console.WriteLine("Attempting to execute script..."); //ScriptProcessor.ChangeActiveScript(scriptObject.script); bTestScript = false; } #endregion #region inputHandler Keys lastPressedKey = Keys.None; if (Keyboard.GetState().GetPressedKeys().Length > 0 && Keyboard.GetState().GetPressedKeys().Length < 2) { lastPressedKey = Keyboard.GetState().GetPressedKeys()[0]; } else if (Keyboard.GetState().GetPressedKeys().Length > 1 && Keyboard.GetState().IsKeyDown(Keys.LeftShift)) { if (Keyboard.GetState().GetPressedKeys()[0] == Keys.LeftShift) { lastPressedKey = Keyboard.GetState().GetPressedKeys()[1]; } else if (Keyboard.GetState().GetPressedKeys()[1] == Keys.LeftShift) { lastPressedKey = Keyboard.GetState().GetPressedKeys()[0]; } } else if (Keyboard.GetState().GetPressedKeys().Length > 0) { lastPressedKey = Keyboard.GetState().GetPressedKeys()[0]; } if (bEnableInput) { if (Keyboard.GetState().IsKeyDown(Keys.LeftShift)) { if (lastPressedKey == Keys.OemPeriod && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "."); } if (lastPressedKey == Keys.OemComma && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "?"); } if (lastPressedKey == ((Keys)(226)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, ">"); } if (lastPressedKey == ((Keys)(192)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "%"); } if (lastPressedKey == ((Keys)(187)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "+"); } } else if (!Keyboard.GetState().IsKeyDown(Keys.LeftShift)) { if (lastPressedKey == (Keys.OemComma) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, ","); } if (lastPressedKey == ((Keys)49) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "&"); } if (lastPressedKey == ((Keys)51) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "\""); } if (lastPressedKey == ((Keys)(52)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "'"); } if (lastPressedKey == ((Keys)(53)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "("); } if (lastPressedKey == ((Keys)(219)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, ")"); } if (lastPressedKey == ((Keys)(56)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "!"); } if (lastPressedKey == ((Keys)(191)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, ":"); } if (lastPressedKey == ((Keys)(226)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "<"); } if (lastPressedKey == ((Keys)(189)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "-"); } if (lastPressedKey == ((Keys)(187)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "="); } if (lastPressedKey == ((Keys)(192)) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "@"); } } if (Keyboard.GetState().GetPressedKeys().Length >= 1) { // Console.Out.WriteLine((int)Keyboard.GetState().GetPressedKeys()[0]); if (!Keyboard.GetState().IsKeyDown(Keys.LeftShift)) { //Numdpad keys are not enabled...yet?... They need manual reprogramming they're values 96-105 starting at 0-9 //From 47-57 0-9 normal keyboard if (((int)Keyboard.GetState().GetPressedKeys()[0] > 57 && (int)Keyboard.GetState().GetPressedKeys()[0] < 91 || (int)Keyboard.GetState().GetPressedKeys()[0] == 32) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (inputText.Length > 0) { inputText = inputText.Insert(inputText.Length, ((char)lastPressedKey).ToString().ToLower()); } else { inputText = ((char)lastPressedKey).ToString().ToLower(); } } else if (inputText.Length > 0 && Keyboard.GetState().IsKeyDown(Keys.Back) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (inputText.Length >= 2) { if (inputText.Substring(inputText.Length - 2, 2).Equals("\n")) { inputText = inputText.Remove(inputText.Length - 2); } else { inputText = inputText.Remove(inputText.Length - 1); } } else { inputText = inputText.Remove(inputText.Length - 1); } } else if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !KeyboardMouseUtility.AnyButtonsPressed()) { inputText = inputText.Insert(inputText.Length, "\n"); } } else if (Keyboard.GetState().IsKeyDown(Keys.LeftShift) && Keyboard.GetState().GetPressedKeys().Length == 2) { //Numdpad keys are not enabled...yet?... They need manual reprogramming they're values 96-105 starting at 0-9 if (((int)Keyboard.GetState().GetPressedKeys()[0] > 47 && (int)Keyboard.GetState().GetPressedKeys()[0] < 91 || (int)Keyboard.GetState().GetPressedKeys()[0] == 32) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (inputText.Length > 0) { inputText = inputText.Insert(inputText.Length, ((char)lastPressedKey).ToString().ToUpper()); } else { inputText = ((char)lastPressedKey).ToString().ToUpper(); } // Console.Out.WriteLine((char)Keyboard.GetState().GetPressedKeys()[0]); } else if (inputText.Length > 0 && Keyboard.GetState().IsKeyDown(Keys.Back) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (inputText.Length >= 2) { if (inputText.Substring(inputText.Length - 2, 2).Equals("\n")) { inputText = inputText.Remove(inputText.Length - 2); } else { inputText = inputText.Remove(inputText.Length - 1); } } else { inputText = inputText.Remove(inputText.Length - 1); } } else if (Keyboard.GetState().IsKeyDown(Keys.Enter) && !KeyboardMouseUtility.AnyButtonsPressed()) { bEnableInput = false; scriptObject.script.scriptContent[currentLineInScript] = inputText; } } } } #endregion #region Input outside typing else { //Re-enable editing if (Keyboard.GetState().IsKeyDown(Keys.Enter) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed()) { bEnableInput = true; } //Add new line downward if (Keyboard.GetState().IsKeyDown(Keys.LeftControl) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (scriptObject.script.scriptContent.Count == 1) { scriptObject.script.scriptContent.Add(inputText); scriptObject.script.scriptContent[currentLineInScript] = ""; inputText = ""; } else { if (currentLineInScript == 0) { scriptObject.script.scriptContent.Insert(0, ""); inputText = ""; } else if (currentLineInScript != 0) { scriptObject.script.scriptContent.Insert(currentLineInScript, ""); inputText = ""; } } } //Add new line upward if (Keyboard.GetState().IsKeyDown(Keys.LeftAlt) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (scriptObject.script.scriptContent.Count == 1) { scriptObject.script.scriptContent.Add(""); scriptObject.script.scriptContent[currentLineInScript] = inputText; inputText = ""; currentLineInScript++; } else { if (currentLineInScript != scriptObject.script.scriptContent.Count) { scriptObject.script.scriptContent.Insert(currentLineInScript + 1, ""); } else if (currentLineInScript == scriptObject.script.scriptContent.Count) { scriptObject.script.scriptContent.Add(""); inputText = ""; } } } //Save current script if (Keyboard.GetState().IsKeyDown(Keys.I) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed()) { scriptObject.script.scriptContent[currentLineInScript] = inputText; EditorFileWriter.ScriptObjectWriter(Environment.CurrentDirectory + @"\Scripts\", scriptObject); } //Load previous script if (Keyboard.GetState().IsKeyDown(Keys.K) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed()) { } if (Keyboard.GetState().IsKeyDown(Keys.Down) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (currentLineInScript < scriptObject.script.scriptContent.Count - 1) { currentLineInScript++; inputText = scriptObject.script.scriptContent[currentLineInScript]; } } if (Keyboard.GetState().IsKeyDown(Keys.Up) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (currentLineInScript > 0) { currentLineInScript--; inputText = scriptObject.script.scriptContent[currentLineInScript]; } } if (Keyboard.GetState().IsKeyDown(Keys.X) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && !KeyboardMouseUtility.AnyButtonsPressed()) { if (currentLineInScript > 0) { scriptObject.script.scriptContent.RemoveAt(currentLineInScript); if (scriptObject.script.scriptContent.Count - 1 < currentLineInScript) { currentLineInScript--; } inputText = scriptObject.script.scriptContent[currentLineInScript]; } } } #endregion if (ScriptProcessor.bScriptRunning) { ScriptProcessor.Update(gameTime); } }
private void button1_Click(object sender, EventArgs e) { LoadSongFile(); EditorFileWriter.SongEncrypter(songFile, cSongFile); }
public override void Update(GameTime gameTime, Game1 game) { if (MapEditor.bIsRunning) { #region firstrun if (firstRun) { mapXSizeInput = new ActiveInput("X-Size map: ", "0", Vector2.Zero, game); mapYSizeInput = new ActiveInput("Y-Size map: ", "0", Vector2.Zero, game); mapNameInput = new ActiveInput("Map name: ", "Map", Vector2.Zero, game); mapXSizeInput.bNumericInputOnly = true; mapYSizeInput.bNumericInputOnly = true; activeInputButtons.Add(mapXSizeInput); activeInputButtons.Add(mapYSizeInput); activeInputButtons.Add(mapNameInput); mapXSizeInput.bHasMinValue = true; mapXSizeInput.minValue = 1; mapYSizeInput.bHasMinValue = true; mapYSizeInput.minValue = 1; firstRun = false; localScenes.Add(mapBuilder); } #endregion if (Game1.bIsDebug) { openMap.Filter = "CGMAPC Files (.cgmapc)|*.cgmapc"; openMap.InitialDirectory = Game1.rootTBAGW; } else { openMap.Filter = "CGMAP Files (.cgmap)|*.cgmap"; openMap.InitialDirectory = Game1.rootContentExtra; } openMap.FilterIndex = 1; openMap.Multiselect = false; saveMap.Filter = "CGMAP Files (.cgmap)|*.cgmap"; saveMap.Title = "Save a CGMAP File"; if (Game1.bIsDebug) { saveMap.InitialDirectory = Game1.rootTBAGW; } else { saveMap.InitialDirectory = Game1.rootContentExtra; } bool usingActiveInput = false; Vector2 EditorCursorPos = Mouse.GetState().Position.ToVector2() + new Vector2(cameraPosX, -cameraPosY); loadMapButton.Update(gameTime); if (loadMapButton.buttonBox.Contains(EditorCursorPos)) { if (Mouse.GetState().LeftButton == ButtonState.Pressed && Game1.bIsActive && !KeyboardMouseUtility.AnyButtonsPressed()) { System.Windows.Forms.DialogResult testDia = openMap.ShowDialog(); if (testDia == System.Windows.Forms.DialogResult.OK && openMap.FileName.Contains(openMap.InitialDirectory)) { // Console.WriteLine("You selected: " + openMap.FileName); loadedMap = EditorFileWriter.MapReader(openMap.FileName); } } } #region MapEditor only logic foreach (var item in activeInputButtons) { item.Update(gameTime); item.Contains(EditorCursorPos); } foreach (var item in activeInputButtons) { if (item.bEnableInput) { usingActiveInput = true; break; } } int i = 0; foreach (var item in activeInputButtons) { item.position = new Vector2(100, 200 + 75 * i); i++; } CreateMapButton.position = new Vector2(activeInputButtons[activeInputButtons.Count - 1].position.X, activeInputButtons[activeInputButtons.Count - 1].position.Y + 75); CreateMapButton.Update(gameTime); if (CreateMapButton.ButtonBox().Contains(EditorCursorPos) && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed()) { bool bCorrectSave = false; while (!bCorrectSave) { try { if (Game1.bIsDebug) { BasicMap newMap = new BasicMap(); newMap.mapName = mapNameInput.ReturnInputString(); saveMap.InitialDirectory = Game1.rootTBAGW; System.Windows.Forms.DialogResult dia = saveMap.ShowDialog(); if (saveMap.FileName != "" && dia == System.Windows.Forms.DialogResult.OK && saveMap.FileName.StartsWith(saveMap.InitialDirectory)) { newMap.mapName = Path.GetFileNameWithoutExtension(saveMap.FileName); mapNameInput.AssignInput(Path.GetFileNameWithoutExtension(saveMap.FileName)); // Console.WriteLine("Line= " + Path.GetDirectoryName(saveMap.FileName)); EditorFileWriter.MapWriter(saveMap.FileName, newMap); Console.WriteLine(newMap.mapLocation); loadedMap = EditorFileWriter.MapReader(saveMap.FileName);; bCorrectSave = true; } else if (dia == System.Windows.Forms.DialogResult.Cancel) { bCorrectSave = true; } else { // Console.WriteLine("Yow"); System.Windows.Forms.MessageBox.Show("Make sure you save the map within the application folder."); } } else { BasicMap newMap = new BasicMap(); newMap.mapName = mapNameInput.ReturnInputString(); saveMap.InitialDirectory = Game1.rootContentExtra; System.Windows.Forms.DialogResult dia = saveMap.ShowDialog(); if (saveMap.FileName != "" && dia == System.Windows.Forms.DialogResult.OK && saveMap.FileName.StartsWith(Game1.rootContentExtra)) { newMap.mapName = Path.GetFileNameWithoutExtension(saveMap.FileName); mapNameInput.AssignInput(Path.GetFileNameWithoutExtension(saveMap.FileName)); // Console.WriteLine("Line= " + Path.GetDirectoryName(saveMap.FileName)); EditorFileWriter.MapWriter(saveMap.FileName, newMap); Console.WriteLine(newMap.mapLocation); loadedMap = EditorFileWriter.MapReader(saveMap.FileName);; bCorrectSave = true; } else if (dia == System.Windows.Forms.DialogResult.Cancel) { bCorrectSave = true; } else { // Console.WriteLine("Yow"); System.Windows.Forms.MessageBox.Show("Make sure you save the map within the application folder."); } } } catch (Exception e) { Console.Out.WriteLine("Error:\n" + e); } } } if (currentScene == 0 && !usingActiveInput) { if (Keyboard.GetState().IsKeyDown(Keys.S)) { cameraPosY -= cameraSpeed; } if (Keyboard.GetState().IsKeyDown(Keys.Z)) { cameraPosY += cameraSpeed; } if (Keyboard.GetState().IsKeyDown(Keys.Q)) { cameraPosX -= cameraSpeed; } if (Keyboard.GetState().IsKeyDown(Keys.D)) { cameraPosX += cameraSpeed; } } #endregion if (loadedMap != default(BasicMap)) { currentScene = (int)MapEditor.MapEditorScenes.MapBuilder; bRerunFileLoader = true; mapBuilder.Start(game, loadedMap); loadedMap = default(BasicMap); bIsRunning = false; } if (Mouse.GetState().RightButton == ButtonState.Pressed && !KeyboardMouseUtility.AnyButtonsPressed() && currentScene > 0) { switch (currentScene) { case (int)MapEditorScenes.MapEditor: System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("You sure want to exit Map editing? NOTE: be sure to save first!", "Leaving", System.Windows.Forms.MessageBoxButtons.YesNo); if (dialogResult == System.Windows.Forms.DialogResult.Yes) { currentScene--; } else if (dialogResult == System.Windows.Forms.DialogResult.No) { //do something else } break; } } } else if (!MapEditor.bIsRunning) { mapBuilder.Update(gameTime, game); } MapEditorMatrix = Matrix.CreateTranslation(-cameraPosX, cameraPosY, 1); }