Hello, I was the founder of the now defunct Free Trek Project, and I'm starting a new project which will build a strategic wargame like the old Empire, but with modern graphics.
I'm using XGame 1.0 right now, and I'm wondering how I can display a complicated window with a 2D scrolling subwindow. I want to have a single window, with the top section being a scrolling map, and the bottom section some graphical controls and displays.
Do you have a suggestion about how this can be done with XGame? Thanks for the excellent and easy to use (so far) library.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are no special facilities to do this. My own choice would be to simply open two separate windows. This does (typically) mean having the user shuffle around with the windows until they're in convenient positions. On the other hand, the user may choose where to place them, and the amount of shuffling necessary is likely to be limited.
In case the status window is small, another choice is to simply re-draw it every scrolling frame. Since scrolling requires the entire window contents to be redrawn anyway, the extra performance penalty is relatively small.
I have considered extending the API to include multiple subwindows. In the KISS nature of Xgame, I'm thinking of replacing XgameOpenWindow and XgameCloseWindow with something like this:
XgameCreateWindow(xsize,ysize,...all other parameters...)
/* Creates window but does not yet display it.
*/
XgamePlaceWindow(container,container_slot, window, x,y)
/* Displays window in given container, on top of anything
* already there. In case the window was already placed
* in the container, it is simply moved. In case the
* window was placed in another container or another
* slot, it is removed first. In case there was already
* another window in the slot, replace that window with
* as little glitches as possible.
* slot < 0 => take any free slot.
* old_win!=null => win is meant to replace old_win.
* old_win is removed from the container with as little
* container==NULL -> place directly on screen; x and y
* are positioning hints only.
*/
XgameDestroyWindow(win);
/* Same as original.
*/
So, Xgame 1.0 programs only need add a XgamePlaceWindow(NULL,-1,win,0,0) after each XgameCreateWindow (which takes the same parameters as XgameOpenWindow) to get the original behaviour, while recursive window embedding is now possible.
The new API should also make it possible to reconfigure windows easily. For example, you might have several different sprite or palette sets to go with different phases or levels of the game. Now, you can properly replace one set with another. For example, suppose you have two windows win1 and win2, which are just different sets for the same window. You can replace one with another by means of XgamePlaceWindow(NULL,0,win<x>,0,0).
Oops, netscape memory leak!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
XgamePlaceWindow(container,container_slot, window, x,y)
/* Displays window in given container, on top of anything
* already there. In case the window was already placed
* in the container, it is simply moved. In case the
* window was placed in another container or another
* slot, it is removed first. In case there was already
* another window in the slot, replace that window with
* as little glitches as possible.
* container_slot < 0 => take any free slot.
* container==NULL -> place directly on screen; x and y
* are positioning hints only.
*/
Regards,
Boris
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, I was the founder of the now defunct Free Trek Project, and I'm starting a new project which will build a strategic wargame like the old Empire, but with modern graphics.
I'm using XGame 1.0 right now, and I'm wondering how I can display a complicated window with a 2D scrolling subwindow. I want to have a single window, with the top section being a scrolling map, and the bottom section some graphical controls and displays.
Do you have a suggestion about how this can be done with XGame? Thanks for the excellent and easy to use (so far) library.
Dear Patrick,
There are no special facilities to do this. My own choice would be to simply open two separate windows. This does (typically) mean having the user shuffle around with the windows until they're in convenient positions. On the other hand, the user may choose where to place them, and the amount of shuffling necessary is likely to be limited.
In case the status window is small, another choice is to simply re-draw it every scrolling frame. Since scrolling requires the entire window contents to be redrawn anyway, the extra performance penalty is relatively small.
I have considered extending the API to include multiple subwindows. In the KISS nature of Xgame, I'm thinking of replacing XgameOpenWindow and XgameCloseWindow with something like this:
XgameCreateWindow(xsize,ysize,...all other parameters...)
/* Creates window but does not yet display it.
*/
XgamePlaceWindow(container,container_slot, window, x,y)
/* Displays window in given container, on top of anything
* already there. In case the window was already placed
* in the container, it is simply moved. In case the
* window was placed in another container or another
* slot, it is removed first. In case there was already
* another window in the slot, replace that window with
* as little glitches as possible.
* slot < 0 => take any free slot.
* old_win!=null => win is meant to replace old_win.
* old_win is removed from the container with as little
* container==NULL -> place directly on screen; x and y
* are positioning hints only.
*/
XgameDestroyWindow(win);
/* Same as original.
*/
So, Xgame 1.0 programs only need add a XgamePlaceWindow(NULL,-1,win,0,0) after each XgameCreateWindow (which takes the same parameters as XgameOpenWindow) to get the original behaviour, while recursive window embedding is now possible.
The new API should also make it possible to reconfigure windows easily. For example, you might have several different sprite or palette sets to go with different phases or levels of the game. Now, you can properly replace one set with another. For example, suppose you have two windows win1 and win2, which are just different sets for the same window. You can replace one with another by means of XgamePlaceWindow(NULL,0,win<x>,0,0).
Oops, netscape memory leak!
Whew, that was close!
I meant to say, of course,
XgamePlaceWindow(container,container_slot, window, x,y)
/* Displays window in given container, on top of anything
* already there. In case the window was already placed
* in the container, it is simply moved. In case the
* window was placed in another container or another
* slot, it is removed first. In case there was already
* another window in the slot, replace that window with
* as little glitches as possible.
* container_slot < 0 => take any free slot.
* container==NULL -> place directly on screen; x and y
* are positioning hints only.
*/
Regards,
Boris