How change dimensions of the capture of screen in the SaveGame and LoadGame?

Started by Mariano Cirigliano, Thu 28/10/2010 23:26:49

Previous topic - Next topic

Mariano Cirigliano

Code:

// main global script file

//--------------------------------------------------------------------------------------------------------------
// Largo's Savegames with Screenshots
//--------------------------------------------------------------------------------------------------------------
// Definitions

// Define screenshot width
#define SL_WIDTH  128 
// Define screenshot height
#define SL_HEIGHT 96 
// Define default screenshot
#define SL_EMPTY_SPRITE 2

// Variables

String text;                                                              // Stores the typed text
int saveslot = 0;                                                         // Stores the selected savegame slot
int totalsaves = 0;                                                       // Stores the total number of savegames
DynamicSprite *screenshot;                                                // Stores the screenshot

// Functions

function sl_save() {
  Wait(1);
  screenshot = DynamicSprite.CreateFromScreenShot(SL_WIDTH, SL_HEIGHT);   // Create screenshot of current game
  if (screenshot != null) {
    btnSaveScreen.NormalGraphic = screenshot.Graphic;                     // Display current screenshot
  }
  txtSaveName.Text = "";                                                  // Clear Text box
  lstSaveGames.FillSaveGameList();                                        // Fill List Box with saved games
  lstSaveGames.SelectedIndex = -1;                                        // Deselect savegame slots
  totalsaves = lstSaveGames.ItemCount;                                    // Count how many saved games there are
  gSave.Visible = true;                                                   // Opens the save GUI
  gSave.Centre();                                                         // Centres the save GUI
  mouse.Mode = eModePointer;                                              // Set the pointer cursor
}

function sl_load() {
  lstLoadGames.FillSaveGameList();                                        // Fill List Box with saved games
  lstLoadGames.SelectedIndex = -1;                                        // Deselect savegame slots
  totalsaves = lstLoadGames.ItemCount;                                    // Count how many saved games there are
  gLoad.Visible = true;                                                   // Opens the load GUI
  gLoad.Centre();                                                         // Centres the load GUI
  mouse.Mode = eModePointer;                                              // Set the pointer cursor
}
//--------------------------------------------------------------------------------------------------------------

#sectionstart game_start  // DO NOT EDIT OR REMOVE THIS LINE
function game_start() { // called when the game starts, before the first room is loaded
game.screenshot_width = 800;
game.screenshot_height = 600;
}

#sectionstart repeatedly_execute  // DO NOT EDIT OR REMOVE THIS LINE
function repeatedly_execute() { // put anything you want to happen every game cycle in here
}

#sectionstart on_key_press  // DO NOT EDIT OR REMOVE THIS LINE
function on_key_press(eKeyCode keycode) { // called when a key is pressed. keycode holds the key's ASCII code
  if (IsGamePaused()) keycode = 0;                          // game paused, so don't react to keypresses
 
  if (keycode == 17) QuitGame(1);                           // Ctrl-Q
  if (keycode == 363) sl_save();                            // F5       
  if (keycode == 365) sl_load();                            // F7
  if (keycode == 367) RestartGame();                        // F9
  if (keycode == 434) SaveScreenShot("screenshot.bmp");     // F12
  if (keycode == 19) Debug(0,0);                            // Ctrl-S, give all inventory
  if (keycode == 22) Debug(1,0);                            // Ctrl-V, version
  if (keycode == 1) Debug(2,0);                             // Ctrl-A, show walkable areas
  if (keycode == 24) Debug(3,0);                            // Ctrl-X, teleport to room
}

#sectionstart on_mouse_click  // DO NOT EDIT OR REMOVE THIS LINE
function on_mouse_click(MouseButton button) { // called when a mouse button is clicked. button is either LEFT or RIGHT
  if (IsGamePaused() == 1) { // Game is paused, so do nothing (ie. don't allow mouse click)
  }
  else if (button == eMouseLeft) ProcessClick(mouse.x,mouse.y, mouse.Mode);
  else if (button == eMouseRight) mouse.SelectNextMode();
}

#sectionstart interface_click  // DO NOT EDIT OR REMOVE THIS LINE
function interface_click(int interface, int button) { // OBSOLETE, NOT USED IN AGS 2.7 AND LATER VERSIONS
}

#sectionstart unhandled_event
function unhandled_event (int what, int type) {
}

function dialog_request(int param) {
}

// Save GUI
function gSave_OnClick(GUI *theGui, MouseButton button) {
  lstSaveGames.SelectedIndex = -1;                              // Deselect savegame slots
}

function btnSaveOK_OnClick(GUIControl *control, MouseButton button) {
  if (lstSaveGames.SelectedIndex >= 0) {                        // If you've selected a savegame slot
    saveslot = lstSaveGames.SelectedIndex;                      // Get the selected savegame
    text = txtSaveName.Text;                                    // Get the typed text
    if (screenshot != null) {
      screenshot.Delete();
      btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot     
    }
    gSave.Visible = false;
    mouse.Mode = eModeWalkto;
    Wait(1);
    SaveGameSlot(lstSaveGames.SaveGameSlots[saveslot],text);    // Overwrites the selected game
  }
  else {                                                        // Save the game in a new slot
    if (totalsaves < 50) {                                      // If the savegame limit is not reached (50)
      text = txtSaveName.Text;                                  // Get the typed text
      if (text == "") {
        Display("Please enter a name for your savegame.");      // If player didn't enter a name, tell them
      }
      else {                                                    // Proceed as usual
        if (screenshot != null) {
          screenshot.Delete();
          btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;        // Resets the screenshot
        }
        gSave.Visible = false;
        mouse.Mode = eModeWalkto;
        Wait(1);
        SaveGameSlot(totalsaves+1,text);                        // Saves game (text as description)
      }
    }
    else Display("All save slots are full. Please overwrite a previous save.");
  }
}

function btnSaveCancel_OnClick(GUIControl *control, MouseButton button) {
  gSave.Visible = false;
  mouse.Mode = eModeWalkto;
  if (screenshot != null) {
    screenshot.Delete();
    btnSaveScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  }
}

function lstSaveGames_OnSelectionChange(GUIControl *control) {
  // Updates textbox contents when selecting an existing slot
  txtSaveName.Text = lstSaveGames.Items[lstSaveGames.SelectedIndex];
}



// Load GUI
function gLoad_OnClick(GUI *theGui, MouseButton button) {
  lstLoadGames.SelectedIndex = -1;                              // Deselect savegame slots
}

function btnLoadOK_OnClick(GUIControl *control, MouseButton button) {
  if (lstLoadGames.SelectedIndex >= 0) {
    saveslot = lstLoadGames.SelectedIndex;                      // Gets the selected slot
    gLoad.Visible = false;
    mouse.Mode = eModeWalkto;
    if (screenshot != null) {
      screenshot.Delete();
      btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot
    }
    RestoreGameSlot(lstLoadGames.SaveGameSlots[saveslot]);      // Restores the selected slot
  }
  else if (totalsaves>0) Display("Please select a savegame.");
  else Display("There are no savegames yet!");
}

function btnDelete_OnClick(GUIControl *control, MouseButton button) {
  if (lstLoadGames.SelectedIndex > -1) {                        // You've selected a saveslot
    saveslot = lstLoadGames.SelectedIndex;                      // Gets the selected slot
    DeleteSaveSlot(savegameindex[saveslot]);                    // Deletes the savegame
    if (screenshot != null) {
      screenshot.Delete();
      btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;            // Resets the screenshot
    }
    lstLoadGames.FillSaveGameList();                            // Fill List Box with saved games
    lstLoadGames.SelectedIndex = -1;                            // Deselect savegame slots
    totalsaves = lstLoadGames.ItemCount;
  }
  else Display("Select a savegame to delete.");
}

function btnLoadCancel_OnClick(GUIControl *control, MouseButton button) {
  gLoad.Visible = false;
  mouse.Mode = eModeWalkto;
  if (screenshot != null) {
    screenshot.Delete();
    btnLoadScreen.NormalGraphic = SL_EMPTY_SPRITE;              // Resets the screenshot
  }
}

function lstLoadGames_OnSelectionChange(GUIControl *control) {
  // Updates screenshot display when selecting a different slot
  saveslot = lstLoadGames.SelectedIndex;                        // Gets the selected slot
  screenshot = DynamicSprite.CreateFromSaveGame(lstLoadGames.SaveGameSlots[saveslot], SL_WIDTH, SL_HEIGHT);
  if (screenshot != null) {
    btnLoadScreen.NormalGraphic = screenshot.Graphic;           // Updates the screenshot
  }
}

How change dimension of the capture of screen in the SaveGame and LoadGame?. ???

SMF spam blocked by CleanTalk