Open_window(): Fix crash when trying to open window larger than screen
it resulted in negative window position...
This commit is contained in:
parent
ea1a58d713
commit
0c6add67f5
33
src/engine.c
33
src/engine.c
@ -1599,11 +1599,20 @@ void Main_handler(void)
|
||||
|
||||
//----------------------- Tracer une fenêtre d'options -----------------------
|
||||
|
||||
void Open_window(word width,word height, const char * title)
|
||||
// Lors de l'appel à cette procédure, la souris doit être affichée.
|
||||
// En sortie de cette procedure, la souris est effacée.
|
||||
/**
|
||||
* Open a GUI window
|
||||
*
|
||||
* @param width window width
|
||||
* @param height window height
|
||||
* @param title window title
|
||||
*
|
||||
* The mouse must be shown before calling this function. The mouse is hidden
|
||||
* when the function returns.
|
||||
*
|
||||
* The function Close_window() must be called afterward.
|
||||
*/
|
||||
void Open_window(word width, word height, const char * title)
|
||||
{
|
||||
//word i,j;
|
||||
size_t title_length;
|
||||
|
||||
Hide_cursor();
|
||||
@ -1620,6 +1629,12 @@ void Open_window(word width,word height, const char * title)
|
||||
|
||||
Windows_open++;
|
||||
|
||||
// Limit the window size to the screen size
|
||||
if (width > Screen_width)
|
||||
width = Screen_width;
|
||||
if (height > Screen_height)
|
||||
height = Screen_height;
|
||||
|
||||
Window_width=width;
|
||||
Window_height=height;
|
||||
|
||||
@ -1627,6 +1642,8 @@ void Open_window(word width,word height, const char * title)
|
||||
Window_pos_X=(Screen_width-(width*Menu_factor_X))>>1;
|
||||
|
||||
Window_pos_Y=(Screen_height-(height*Menu_factor_Y))>>1;
|
||||
|
||||
GFX2_Log(GFX2_DEBUG, "Open_window(%d, %d, \"%s\") pos (%d,%d)\n", width, height, title, Window_pos_X, Window_pos_Y);
|
||||
|
||||
Window_draggable=1;
|
||||
|
||||
@ -1682,9 +1699,13 @@ void Open_window(word width,word height, const char * title)
|
||||
|
||||
//----------------------- Fermer une fenêtre d'options -----------------------
|
||||
|
||||
/**
|
||||
* Close a window previously open with Open_window()
|
||||
*
|
||||
* The mouse must be shown when this functions is called.
|
||||
* It is hidden when the function returns.
|
||||
*/
|
||||
void Close_window(void)
|
||||
// Lors de l'appel à cette procedure, la souris doit être affichée.
|
||||
// En sortie de cette procedure, la souris est effacée.
|
||||
{
|
||||
T_Normal_button * temp1;
|
||||
T_Palette_button * temp2;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user