void CheckMouseInput(const INPUT_RECORD &InputRecord) { // Get the current position of the mouse in the console window g_cursorPos = InputRecord.Event.MouseEvent.dwMousePosition; //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If we have the exit map open (destination map) then we don't want the // user to click on the editor tiles since it will screw up our placing // of the destination point, so we quit this function if they try that. if( (g_cursorPos.Y >= MAP_HEIGHT - EDITOR_HEIGHT) && g_bExitMapOpen) return; //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If the user hits the left mouse button if(InputRecord.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { // Here we check if the user chose a tile from our editor. if(g_cursorPos.Y > MAP_HEIGHT - EDITOR_HEIGHT) { // Get the character chosen from the editor CHAR_INFO chosenTile = g_Map.GetEditorSelection(g_cursorPos.X, g_cursorPos.Y); CHAR_INFO cursorTile = chosenTile; // If we already have a tile selected, let's grab it's image instead if(g_pCursorTile != NULL) cursorTile = g_pCursorTile->GetChar(); // Check if the user clicked the color tiles if(g_cursorPos.X >= 15 && g_cursorPos.Y == (MAP_HEIGHT - 1)) { CHAR_INFO newTile; // Create a new tile to work with for color // Check if the user clicked the background colors, otherwise it was foreground if(g_cursorPos.X > 30) newTile = g_Map.AddNewBackground(cursorTile, chosenTile); else newTile = g_Map.AddNewForeground(cursorTile, chosenTile); // Apply the new tile with it's new color to our cursor. g_vTiles[g_vTiles.size() - 1].SetChar(newTile); } else { // Otherwise, if we didn't choose a color, then we must // have chosen a new tile character from the editor. chosenTile.Attributes = cursorTile.Attributes; g_vTiles[g_vTiles.size() - 1].SetChar(chosenTile); // Let's set the cursor to a normal tile index and type g_pCursorTile = &g_vTiles[g_vTiles.size() - 1]; g_Map.SetCurrentType(TILE_TYPE); } } else { // If we have a tile, let's insert a tile into the map if(g_pCursorTile != NULL) g_pCurrentMap->InsertTile(g_pCursorTile, g_cursorPos.X, g_cursorPos.Y); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // After we insert a tile, we want to check if that tile was an exit. If // it was, we need to handle the exits because it might either be a placing // of a destination exit or the end of a list of exits. This is why the // function HandleExitTiles() gets called twice. We first call it when // we are done placing our desired exit(s) on the normal map, which will // bring up a prompt to open the destination map. It's called again // when we choose the destination point on the exit map. 1 + 1 = ... 2 :) // Here we check if our current type are exits if(g_pCurrentMap->GetCurrentType() == EXIT_TYPE) { // If we don't have the shift key down or the exit map is open // we want to stop setting exits and handle the exits that were just set. if(!g_bShiftKeyDown || g_bExitMapOpen) HandleExitTiles(); } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// } } // Here we check if the right mouse button was clicked if(InputRecord.Event.MouseEvent.dwButtonState == RIGHTMOST_BUTTON_PRESSED) { // Here we either delete a tile on the map, or delete the cursor tile if(g_pCursorTile == NULL) { // Delete a tile under our cursor position on the map g_pCurrentMap->DeleteTile(g_cursorPos.X, g_cursorPos.Y); } else g_pCursorTile = NULL; //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If the user is in the middle of setting exits and decide to abort, we want to // still let them right click to destroy the cursor tile and unset exit tiles. // We need to handle both situations of the user having placed exits and not yet // opened a destination map, as well as having the destination map open as well. // So, after the cursor tile is delete, if the exit map is open we want to return // to the previous map and delete the blank exits that were never filled in with // a destination point. If the destination map isn't open, we still want to get // rid of the wasted exits already set on the map. // Check if the current tile type are exits if(g_pCurrentMap->GetCurrentType() == EXIT_TYPE) { // Check if our destination map is open and we need to abort to the previous map if(g_bExitMapOpen) { // To abort, we need to set the current map pointer back and reset the flag g_pCurrentMap = &g_Map; g_bExitMapOpen = false; } // Go through and delete all the useless exits and redraw the screen g_pCurrentMap->DeleteBlankExits(); g_pCurrentMap->Draw(); } //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// } }
void CheckMouseInput(const INPUT_RECORD &InputRecord) { // Get the current position of the mouse in the console window g_cursorPos = InputRecord.Event.MouseEvent.dwMousePosition; // If the user hits the left mouse button if(InputRecord.Event.MouseEvent.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED) { // Here we check if the user chose a tile from our editor. if(g_cursorPos.Y > MAP_HEIGHT - EDITOR_HEIGHT) { // Get the character chosen from the editor CHAR_INFO chosenTile = g_Map.GetEditorSelection(g_cursorPos.X, g_cursorPos.Y); CHAR_INFO cursorTile = chosenTile; // If we already have a tile selected, let's grab it's image instead if(g_pCursorTile != NULL) cursorTile = g_pCursorTile->GetChar(); // Check if the user clicked the color tiles if(g_cursorPos.X >= 15 && g_cursorPos.Y == (MAP_HEIGHT - 1)) { CHAR_INFO newTile; // Create a new tile to work with for color // Check if the user clicked the background colors, otherwise it was foreground if(g_cursorPos.X > 30) newTile = g_Map.AddNewBackground(cursorTile, chosenTile); else newTile = g_Map.AddNewForeground(cursorTile, chosenTile); // Apply the new tile with it's new color to our cursor. g_vTiles[g_vTiles.size() - 1].SetChar(newTile); } else { // Otherwise, if we didn't choose a color, then we must // have chosen a new tile character from the editor. chosenTile.Attributes = cursorTile.Attributes; g_vTiles[g_vTiles.size() - 1].SetChar(chosenTile); // Let's set the cursor to a normal tile index and type g_pCursorTile = &g_vTiles[g_vTiles.size() - 1]; g_Map.SetCurrentType(TILE_TYPE); } } else { // If we have a tile, let's insert a tile into the map if(g_pCursorTile != NULL) g_pCurrentMap->InsertTile(g_pCursorTile, g_cursorPos.X, g_cursorPos.Y); } } // Here we check if the right mouse button was clicked if(InputRecord.Event.MouseEvent.dwButtonState == RIGHTMOST_BUTTON_PRESSED) { // Here we either delete a tile on the map, or delete the cursor tile if(g_pCursorTile == NULL) { // Delete a tile under our cursor position on the map g_pCurrentMap->DeleteTile(g_cursorPos.X, g_cursorPos.Y); } else g_pCursorTile = NULL; } }