Changeset - r5122:35740e0112f6
[Not reviewed]
master
0 3 0
Darkvater - 18 years ago 2006-11-18 13:54:33
darkvater@openttd.org
(svn r7202) -Codechange: Move _viewports and _active_viewports local to viewport.c and have them
called from the appropiate places in window.c
3 files changed with 24 insertions and 14 deletions:
0 comments (0 inline, 0 general)
viewport.c
Show inline comments
 
@@ -23,6 +23,12 @@
 

	
 
#define VIEWPORT_DRAW_MEM (65536 * 2)
 

	
 
/* viewport.c */
 
// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
 
static ViewPort _viewports[25 - 2];
 
static uint32 _active_viewports;    ///< bitmasked variable where each bit signifies if a viewport is in use or not
 
assert_compile(lengthof(_viewports) < sizeof(_active_viewports) * 8);
 

	
 
static bool _added_tile_sprite;
 
static bool _offset_ground_sprites;
 

	
 
@@ -119,6 +125,18 @@ static Point MapXYZToViewport(const View
 
	return p;
 
}
 

	
 
void InitViewports(void) {
 
	memset(_viewports, 0, sizeof(_viewports));
 
	_active_viewports = 0;
 
}
 

	
 
void DeleteWindowViewport(Window *w)
 
{
 
	CLRBIT(_active_viewports, w->viewport - _viewports);
 
	w->viewport->width = 0;
 
	w->viewport = NULL;
 
}
 

	
 
void AssignWindowViewport(Window *w, int x, int y,
 
	int width, int height, uint32 follow_flags, byte zoom)
 
{
 
@@ -126,11 +144,11 @@ void AssignWindowViewport(Window *w, int
 
	Point pt;
 
	uint32 bit;
 

	
 
	for (vp = _viewports, bit = 1; ; vp++, bit <<= 1) {
 
	for (vp = _viewports, bit = 0; ; vp++, bit++) {
 
		assert(vp != endof(_viewports));
 
		if (vp->width == 0) break;
 
	}
 
	_active_viewports |= bit;
 
	SETBIT(_active_viewports, bit);
 

	
 
	vp->left = x + w->left;
 
	vp->top = y + w->top;
viewport.h
Show inline comments
 
@@ -16,6 +16,8 @@ struct ViewPort {
 
void SetSelectionRed(bool);
 

	
 
/* viewport.c */
 
void InitViewports(void);
 
void DeleteWindowViewport(Window *w);
 
void AssignWindowViewport(Window *w, int x, int y,
 
	int width, int height, uint32 follow_flags, byte zoom);
 
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
 
@@ -139,11 +141,6 @@ typedef struct TileHighlightData {
 
// common button handler
 
bool HandlePlacePushButton(Window *w, int widget, uint32 cursor, int mode, PlaceProc *placeproc);
 

	
 
/* viewport.c */
 
// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
 
VARDEF ViewPort _viewports[25 - 2];
 
VARDEF uint32 _active_viewports;
 

	
 
VARDEF Point _tile_fract_coords;
 

	
 
extern TileHighlightData _thd;
window.c
Show inline comments
 
@@ -302,11 +302,7 @@ void DeleteWindow(Window *w)
 

	
 
	w = FindWindowById(wc, wn);
 

	
 
	if (w->viewport != NULL) {
 
		CLRBIT(_active_viewports, w->viewport - _viewports);
 
		w->viewport->width = 0;
 
		w->viewport = NULL;
 
	}
 
	if (w->viewport != NULL) DeleteWindowViewport(w);
 

	
 
	SetWindowDirty(w);
 

	
 
@@ -832,8 +828,7 @@ void InitWindowSystem(void)
 

	
 
	memset(&_windows, 0, sizeof(_windows));
 
	_last_window = _windows;
 
	memset(_viewports, 0, sizeof(_viewports));
 
	_active_viewports = 0;
 
	InitViewports();
 
	_no_scroll = 0;
 
}
 

	
0 comments (0 inline, 0 general)