mirror of https://github.com/OpenTTD/OpenTTD
(svn r159) -Fix: w->custom[] was too small for 64bit pointers
parent
0fe07eac63
commit
1846563cf8
136
window.c
136
window.c
|
@ -21,9 +21,9 @@ void DispatchLeftClickEvent(Window *w, int x, int y) {
|
||||||
e.event = WE_CLICK;
|
e.event = WE_CLICK;
|
||||||
|
|
||||||
if (w->desc_flags & WDF_DEF_WIDGET) {
|
if (w->desc_flags & WDF_DEF_WIDGET) {
|
||||||
e.click.widget = GetWidgetFromPos(w, x, y);
|
e.click.widget = GetWidgetFromPos(w, x, y);
|
||||||
if (e.click.widget < 0) return; /* exit if clicked outside of widgets */
|
if (e.click.widget < 0) return; /* exit if clicked outside of widgets */
|
||||||
|
|
||||||
wi = &w->widget[e.click.widget];
|
wi = &w->widget[e.click.widget];
|
||||||
|
|
||||||
if (wi->type & 0xE0) {
|
if (wi->type & 0xE0) {
|
||||||
|
@ -38,21 +38,21 @@ void DispatchLeftClickEvent(Window *w, int x, int y) {
|
||||||
case WWT_NODISTXTBTN:
|
case WWT_NODISTXTBTN:
|
||||||
if (HASBIT(w->disabled_state, e.click.widget))
|
if (HASBIT(w->disabled_state, e.click.widget))
|
||||||
return; /* don't allow click if disabled */
|
return; /* don't allow click if disabled */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_HSCROLLBAR) {
|
} else if (wi->type == WWT_SCROLLBAR || wi->type == WWT_HSCROLLBAR) {
|
||||||
ScrollbarClickHandler(w, wi, e.click.pt.x, e.click.pt.y);
|
ScrollbarClickHandler(w, wi, e.click.pt.x, e.click.pt.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->wndproc(w, &e);
|
w->wndproc(w, &e);
|
||||||
|
|
||||||
if (w->desc_flags & WDF_STD_BTN) {
|
if (w->desc_flags & WDF_STD_BTN) {
|
||||||
if (e.click.widget == 0) DeleteWindow(w);
|
if (e.click.widget == 0) DeleteWindow(w);
|
||||||
else {
|
else {
|
||||||
if (e.click.widget == 1) {
|
if (e.click.widget == 1) {
|
||||||
if (_ctrl_pressed)
|
if (_ctrl_pressed)
|
||||||
StartWindowSizing(w);
|
StartWindowSizing(w);
|
||||||
else
|
else
|
||||||
StartWindowDrag(w);
|
StartWindowDrag(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ void DispatchRightClickEvent(Window *w, int x, int y) {
|
||||||
e.event = WE_RCLICK;
|
e.event = WE_RCLICK;
|
||||||
e.click.pt.x = x;
|
e.click.pt.x = x;
|
||||||
e.click.pt.y = y;
|
e.click.pt.y = y;
|
||||||
w->wndproc(w, &e);
|
w->wndproc(w, &e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,12 +103,12 @@ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
|
||||||
_cur_dpi = &bk;
|
_cur_dpi = &bk;
|
||||||
|
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (right > w->left &&
|
if (right > w->left &&
|
||||||
bottom > w->top &&
|
bottom > w->top &&
|
||||||
left < w->left + w->width &&
|
left < w->left + w->width &&
|
||||||
top < w->top + w->height) {
|
top < w->top + w->height) {
|
||||||
DrawOverlappedWindow(w, left, top, right, bottom);
|
DrawOverlappedWindow(w, left, top, right, bottom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
|
||||||
bottom > v->top &&
|
bottom > v->top &&
|
||||||
left < v->left + v->width &&
|
left < v->left + v->width &&
|
||||||
top < v->top + v->height) {
|
top < v->top + v->height) {
|
||||||
|
|
||||||
if (left < (x=v->left)) {
|
if (left < (x=v->left)) {
|
||||||
DrawOverlappedWindow(w, left, top, x, bottom);
|
DrawOverlappedWindow(w, left, top, x, bottom);
|
||||||
DrawOverlappedWindow(w, x, top, right, bottom);
|
DrawOverlappedWindow(w, x, top, right, bottom);
|
||||||
|
@ -152,7 +152,7 @@ void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
DrawPixelInfo *dp = _cur_dpi;
|
DrawPixelInfo *dp = _cur_dpi;
|
||||||
dp->width = right - left;
|
dp->width = right - left;
|
||||||
dp->height = bottom - top;
|
dp->height = bottom - top;
|
||||||
dp->left = left - w->left;
|
dp->left = left - w->left;
|
||||||
|
@ -175,7 +175,7 @@ void SetWindowDirty(Window *w)
|
||||||
{
|
{
|
||||||
if (w == NULL)
|
if (w == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height);
|
SetDirtyBlocks(w->left, w->top, w->left + w->width, w->top + w->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,11 +220,11 @@ Window *FindWindowById(WindowClass cls, WindowNumber number)
|
||||||
Window *w;
|
Window *w;
|
||||||
|
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (w->window_class == cls &&
|
if (w->window_class == cls &&
|
||||||
w->window_number == number) {
|
w->window_number == number) {
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -232,7 +232,7 @@ Window *FindWindowById(WindowClass cls, WindowNumber number)
|
||||||
void DeleteWindowById(WindowClass cls, WindowNumber number)
|
void DeleteWindowById(WindowClass cls, WindowNumber number)
|
||||||
{
|
{
|
||||||
DeleteWindow(FindWindowById(cls, number));
|
DeleteWindow(FindWindowById(cls, number));
|
||||||
}
|
}
|
||||||
|
|
||||||
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number)
|
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number)
|
||||||
{
|
{
|
||||||
|
@ -277,7 +277,7 @@ Window *AllocateWindow(
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget)
|
const Widget *widget)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +292,7 @@ restart:;
|
||||||
|
|
||||||
if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR &&
|
if (w->window_class != WC_MAIN_WINDOW && w->window_class != WC_MAIN_TOOLBAR &&
|
||||||
w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW) {
|
w->window_class != WC_STATUS_BAR && w->window_class != WC_NEWS_WINDOW) {
|
||||||
|
|
||||||
DeleteWindow(w);
|
DeleteWindow(w);
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
|
@ -338,16 +338,16 @@ restart:;
|
||||||
w->hscroll.count = 0;
|
w->hscroll.count = 0;
|
||||||
w->widget = widget;
|
w->widget = widget;
|
||||||
|
|
||||||
((uint32*)w->custom)[0] = 0;
|
{
|
||||||
((uint32*)w->custom)[1] = 0;
|
int i;
|
||||||
((uint32*)w->custom)[2] = 0;
|
for (i=0;i<lengthof(w->custom);i++)
|
||||||
((uint32*)w->custom)[3] = 0;
|
w->custom[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
_last_window++;
|
_last_window++;
|
||||||
|
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
|
|
||||||
CallWindowEventNP(w, WE_CREATE);
|
CallWindowEventNP(w, WE_CREATE);
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
|
@ -358,17 +358,17 @@ Window *AllocateWindowAutoPlace2(
|
||||||
WindowNumber exist_num,
|
WindowNumber exist_num,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget)
|
const Widget *widget)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
int x;
|
int x;
|
||||||
|
|
||||||
w = FindWindowById(exist_class, exist_num);
|
w = FindWindowById(exist_class, exist_num);
|
||||||
if (w == NULL || w->left >= (_screen.width-20) || w->left <= -60 || w->top >= (_screen.height-20)) {
|
if (w == NULL || w->left >= (_screen.width-20) || w->left <= -60 || w->top >= (_screen.height-20)) {
|
||||||
return AllocateWindowAutoPlace(width,height,proc,cls,widget);
|
return AllocateWindowAutoPlace(width,height,proc,cls,widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
x = w->left;
|
x = w->left;
|
||||||
if (x > _screen.width - width)
|
if (x > _screen.width - width)
|
||||||
|
@ -398,17 +398,17 @@ static bool IsGoodAutoPlace1(int left, int top)
|
||||||
if (left < 0 || top < 22 || right > _screen.width || bottom > _screen.height)
|
if (left < 0 || top < 22 || right > _screen.width || bottom > _screen.height)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Make sure it is not obscured by any window.
|
// Make sure it is not obscured by any window.
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (w->window_class == WC_MAIN_WINDOW)
|
if (w->window_class == WC_MAIN_WINDOW)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (right > w->left &&
|
if (right > w->left &&
|
||||||
w->left + w->width > left &&
|
w->left + w->width > left &&
|
||||||
bottom > w->top &&
|
bottom > w->top &&
|
||||||
w->top + w->height > top)
|
w->top + w->height > top)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -428,17 +428,17 @@ static bool IsGoodAutoPlace2(int left, int top)
|
||||||
if (top < 22 || top > _screen.height - (height>>2))
|
if (top < 22 || top > _screen.height - (height>>2))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Make sure it is not obscured by any window.
|
// Make sure it is not obscured by any window.
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (w->window_class == WC_MAIN_WINDOW)
|
if (w->window_class == WC_MAIN_WINDOW)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (left + width > w->left &&
|
if (left + width > w->left &&
|
||||||
w->left + w->width > left &&
|
w->left + w->width > left &&
|
||||||
top + height > w->top &&
|
top + height > w->top &&
|
||||||
w->top + w->height > top)
|
w->top + w->height > top)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -464,8 +464,8 @@ Point GetAutoPlacePosition(int width, int height) {
|
||||||
if (IsGoodAutoPlace1(w->left- width-2,w->top+w->height-height)) goto ok_pos;
|
if (IsGoodAutoPlace1(w->left- width-2,w->top+w->height-height)) goto ok_pos;
|
||||||
if (IsGoodAutoPlace1(w->left+w->width-width,w->top+w->height+2)) goto ok_pos;
|
if (IsGoodAutoPlace1(w->left+w->width-width,w->top+w->height+2)) goto ok_pos;
|
||||||
if (IsGoodAutoPlace1(w->left+w->width-width,w->top- height-2)) goto ok_pos;
|
if (IsGoodAutoPlace1(w->left+w->width-width,w->top- height-2)) goto ok_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (w->window_class == WC_MAIN_WINDOW)
|
if (w->window_class == WC_MAIN_WINDOW)
|
||||||
continue;
|
continue;
|
||||||
|
@ -478,7 +478,7 @@ Point GetAutoPlacePosition(int width, int height) {
|
||||||
|
|
||||||
{
|
{
|
||||||
int left=0,top=24;
|
int left=0,top=24;
|
||||||
|
|
||||||
restart:;
|
restart:;
|
||||||
for(w=_windows; w!=_last_window; w++) {
|
for(w=_windows; w!=_last_window; w++) {
|
||||||
if (w->left == left && w->top == top) {
|
if (w->left == left && w->top == top) {
|
||||||
|
@ -487,12 +487,12 @@ restart:;
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pt.x = left;
|
pt.x = left;
|
||||||
pt.y = top;
|
pt.y = top;
|
||||||
return pt;
|
return pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
ok_pos:;
|
ok_pos:;
|
||||||
pt.x = _awap_r.left;
|
pt.x = _awap_r.left;
|
||||||
pt.y = _awap_r.top;
|
pt.y = _awap_r.top;
|
||||||
|
@ -502,7 +502,7 @@ ok_pos:;
|
||||||
Window *AllocateWindowAutoPlace(
|
Window *AllocateWindowAutoPlace(
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget) {
|
const Widget *widget) {
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ Window *AllocateWindowDesc(const WindowDesc *desc)
|
||||||
Point pt;
|
Point pt;
|
||||||
Window *w;
|
Window *w;
|
||||||
|
|
||||||
if (desc->parent_cls != WC_MAIN_WINDOW &&
|
if (desc->parent_cls != WC_MAIN_WINDOW &&
|
||||||
(w = FindWindowById(desc->parent_cls, _alloc_wnd_parent_num), _alloc_wnd_parent_num=0, w) != NULL &&
|
(w = FindWindowById(desc->parent_cls, _alloc_wnd_parent_num), _alloc_wnd_parent_num=0, w) != NULL &&
|
||||||
w->left < _screen.width-20 && w->left > -60 && w->top < _screen.height-20) {
|
w->left < _screen.width-20 && w->left > -60 && w->top < _screen.height-20) {
|
||||||
pt.x = w->left + 10;
|
pt.x = w->left + 10;
|
||||||
|
@ -599,7 +599,7 @@ void DecreaseWindowCounters()
|
||||||
|
|
||||||
for(w=_last_window; w != _windows;) {
|
for(w=_last_window; w != _windows;) {
|
||||||
--w;
|
--w;
|
||||||
|
|
||||||
if (w->flags4&WF_TIMEOUT_MASK && !(--w->flags4&WF_TIMEOUT_MASK)) {
|
if (w->flags4&WF_TIMEOUT_MASK && !(--w->flags4&WF_TIMEOUT_MASK)) {
|
||||||
CallWindowEventNP(w, WE_TIMEOUT);
|
CallWindowEventNP(w, WE_TIMEOUT);
|
||||||
if (w->desc_flags & WDF_UNCLICK_BUTTONS)
|
if (w->desc_flags & WDF_UNCLICK_BUTTONS)
|
||||||
|
@ -644,7 +644,7 @@ bool HandleDragDrop()
|
||||||
|
|
||||||
if (_left_button_down)
|
if (_left_button_down)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
w = GetCallbackWnd();
|
w = GetCallbackWnd();
|
||||||
|
|
||||||
ResetObjectToPlace();
|
ResetObjectToPlace();
|
||||||
|
@ -688,7 +688,7 @@ bool HandlePopupMenu()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleWindowDragging()
|
bool HandleWindowDragging()
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
int x, y, t;
|
int x, y, t;
|
||||||
|
@ -700,7 +700,7 @@ bool HandleWindowDragging()
|
||||||
// Otherwise find the window...
|
// Otherwise find the window...
|
||||||
for(w=_windows; w != _last_window; w++) {
|
for(w=_windows; w != _last_window; w++) {
|
||||||
if (w->flags4&(WF_DRAGGING|WF_SIZING)) {
|
if (w->flags4&(WF_DRAGGING|WF_SIZING)) {
|
||||||
|
|
||||||
// Stop the dragging if the left mouse button was released
|
// Stop the dragging if the left mouse button was released
|
||||||
if (!_left_button_down) {
|
if (!_left_button_down) {
|
||||||
w->flags4 &= ~(WF_DRAGGING | WF_SIZING);
|
w->flags4 &= ~(WF_DRAGGING | WF_SIZING);
|
||||||
|
@ -733,7 +733,7 @@ bool HandleWindowDragging()
|
||||||
w->viewport->top += y;
|
w->viewport->top += y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// And also mark the new position dirty.
|
// And also mark the new position dirty.
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
return false;
|
return false;
|
||||||
|
@ -784,7 +784,7 @@ bool HandleScrollbarScrolling()
|
||||||
w->flags4 &= ~WF_SCROLL_MIDDLE;
|
w->flags4 &= ~WF_SCROLL_MIDDLE;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (w->flags4 & WF_HSCROLL) {
|
if (w->flags4 & WF_HSCROLL) {
|
||||||
sb = &w->hscroll;
|
sb = &w->hscroll;
|
||||||
|
@ -801,14 +801,14 @@ bool HandleScrollbarScrolling()
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_scrolling_scrollbar = false;
|
_scrolling_scrollbar = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleViewportScroll()
|
bool HandleViewportScroll()
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
ViewPort *vp;
|
ViewPort *vp;
|
||||||
|
@ -823,7 +823,7 @@ stop_capt:;
|
||||||
_scrolling_viewport = false;
|
_scrolling_viewport = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
|
||||||
if (w == NULL) goto stop_capt;
|
if (w == NULL) goto stop_capt;
|
||||||
|
|
||||||
|
@ -838,9 +838,9 @@ stop_capt:;
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// scroll the smallmap ?
|
// scroll the smallmap ?
|
||||||
|
|
||||||
_cursor.fix_at = true;
|
_cursor.fix_at = true;
|
||||||
|
|
||||||
dx = _cursor.delta.x;
|
dx = _cursor.delta.x;
|
||||||
dy = _cursor.delta.y;
|
dy = _cursor.delta.y;
|
||||||
|
|
||||||
|
@ -904,8 +904,8 @@ static Window *MaybeBringWindowToFront(Window *w)
|
||||||
w->top + w->height <= u->top ||
|
w->top + w->height <= u->top ||
|
||||||
u->top + u->height <= w->top)
|
u->top + u->height <= w->top)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
return BringWindowToFront(w);
|
return BringWindowToFront(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return w;
|
return w;
|
||||||
|
@ -915,7 +915,7 @@ static void HandleKeypress(uint32 key)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
WindowEvent we;
|
WindowEvent we;
|
||||||
|
|
||||||
// Setup event
|
// Setup event
|
||||||
we.keypress.event = WE_KEYPRESS;
|
we.keypress.event = WE_KEYPRESS;
|
||||||
we.keypress.ascii = key & 0xFF;
|
we.keypress.ascii = key & 0xFF;
|
||||||
|
@ -965,7 +965,7 @@ void MouseLoop()
|
||||||
mousewheel = _cursor.wheel;
|
mousewheel = _cursor.wheel;
|
||||||
_cursor.wheel = 0;
|
_cursor.wheel = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecreaseWindowCounters();
|
DecreaseWindowCounters();
|
||||||
HandlePlacePresize();
|
HandlePlacePresize();
|
||||||
UpdateTileSelection();
|
UpdateTileSelection();
|
||||||
|
@ -986,7 +986,7 @@ void MouseLoop()
|
||||||
|
|
||||||
if (!HandleViewportScroll())
|
if (!HandleViewportScroll())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
x = _cursor.pos.x;
|
x = _cursor.pos.x;
|
||||||
y = _cursor.pos.y;
|
y = _cursor.pos.y;
|
||||||
|
|
||||||
|
@ -1005,7 +1005,7 @@ void MouseLoop()
|
||||||
else if (15-(vp->width-x) > 0) { WP(w,vp_d).scrollpos_x += (15-(vp->width-x))*scrollspeed << vp->zoom; }
|
else if (15-(vp->width-x) > 0) { WP(w,vp_d).scrollpos_x += (15-(vp->width-x))*scrollspeed << vp->zoom; }
|
||||||
if (y-15<0) { WP(w,vp_d).scrollpos_y += (y-15)*scrollspeed << vp->zoom; }
|
if (y-15<0) { WP(w,vp_d).scrollpos_y += (y-15)*scrollspeed << vp->zoom; }
|
||||||
else if (15-(vp->height-y) > 0) { WP(w,vp_d).scrollpos_y += (15-(vp->height-y))*scrollspeed << vp->zoom; }
|
else if (15-(vp->height-y) > 0) { WP(w,vp_d).scrollpos_y += (15-(vp->height-y))*scrollspeed << vp->zoom; }
|
||||||
#undef scrollspeed
|
#undef scrollspeed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1032,7 +1032,7 @@ void MouseLoop()
|
||||||
_pause != 0 &&
|
_pause != 0 &&
|
||||||
!_cheats.build_in_pause.value)
|
!_cheats.build_in_pause.value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_thd.place_mode == 0) {
|
if (_thd.place_mode == 0) {
|
||||||
HandleViewportClicked(vp, x, y);
|
HandleViewportClicked(vp, x, y);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1092,7 +1092,7 @@ void UpdateWindows()
|
||||||
}
|
}
|
||||||
// Redraw mouse cursor in case it was hidden
|
// Redraw mouse cursor in case it was hidden
|
||||||
DrawMouseCursor();
|
DrawMouseCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GetMenuItemIndex(Window *w, int x, int y)
|
int GetMenuItemIndex(Window *w, int x, int y)
|
||||||
|
@ -1121,11 +1121,11 @@ void InvalidateWidget(Window *w, byte widget_index)
|
||||||
const Widget *wi = &w->widget[widget_index];
|
const Widget *wi = &w->widget[widget_index];
|
||||||
// if (wi->left != -2) {
|
// if (wi->left != -2) {
|
||||||
SetDirtyBlocks(
|
SetDirtyBlocks(
|
||||||
w->left + wi->left,
|
w->left + wi->left,
|
||||||
w->top + wi->top,
|
w->top + wi->top,
|
||||||
w->left + wi->right + 1,
|
w->left + wi->right + 1,
|
||||||
w->top + wi->bottom + 1);
|
w->top + wi->bottom + 1);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index)
|
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index)
|
||||||
|
@ -1176,7 +1176,7 @@ void DeleteNonVitalWindows()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int PositionMainToolbar(Window *w)
|
int PositionMainToolbar(Window *w)
|
||||||
{
|
{
|
||||||
DEBUG(misc, 1) ("Repositioning Main Toolbar...");
|
DEBUG(misc, 1) ("Repositioning Main Toolbar...");
|
||||||
|
|
||||||
|
@ -1198,7 +1198,7 @@ void RelocateAllWindows(int neww, int newh)
|
||||||
|
|
||||||
for(w=_windows; w!= _last_window ;w++) {
|
for(w=_windows; w!= _last_window ;w++) {
|
||||||
int left, top;
|
int left, top;
|
||||||
|
|
||||||
if (w->window_class == WC_MAIN_WINDOW) {
|
if (w->window_class == WC_MAIN_WINDOW) {
|
||||||
ViewPort *vp = w->viewport;
|
ViewPort *vp = w->viewport;
|
||||||
vp->width = w->width = neww;
|
vp->width = w->width = neww;
|
||||||
|
@ -1213,7 +1213,7 @@ void RelocateAllWindows(int neww, int newh)
|
||||||
if (w->window_class == WC_MAIN_TOOLBAR) {
|
if (w->window_class == WC_MAIN_TOOLBAR) {
|
||||||
top = w->top;
|
top = w->top;
|
||||||
left = PositionMainToolbar(w); // changes toolbar orientation
|
left = PositionMainToolbar(w); // changes toolbar orientation
|
||||||
} else if (w->window_class == WC_SELECT_GAME || w->window_class == WC_GAME_OPTIONS || w->window_class == WC_NETWORK_WINDOW){
|
} else if (w->window_class == WC_SELECT_GAME || w->window_class == WC_GAME_OPTIONS || w->window_class == WC_NETWORK_WINDOW){
|
||||||
top = (newh - w->height) >> 1;
|
top = (newh - w->height) >> 1;
|
||||||
left = (neww - w->width) >> 1;
|
left = (neww - w->width) >> 1;
|
||||||
} else if (w->window_class == WC_NEWS_WINDOW) {
|
} else if (w->window_class == WC_NEWS_WINDOW) {
|
||||||
|
@ -1221,7 +1221,7 @@ void RelocateAllWindows(int neww, int newh)
|
||||||
left = (neww - w->width) >> 1;
|
left = (neww - w->width) >> 1;
|
||||||
} else if (w->window_class == WC_STATUS_BAR) {
|
} else if (w->window_class == WC_STATUS_BAR) {
|
||||||
top = newh - w->height;
|
top = newh - w->height;
|
||||||
left = (neww - w->width) >> 1;
|
left = (neww - w->width) >> 1;
|
||||||
} else {
|
} else {
|
||||||
left = w->left;
|
left = w->left;
|
||||||
if (left + (w->width>>1) >= neww) left = neww - w->width;
|
if (left + (w->width>>1) >= neww) left = neww - w->width;
|
||||||
|
|
48
window.h
48
window.h
|
@ -66,7 +66,7 @@ enum WindowKeyCodes {
|
||||||
WKC_CTRL = 0x4000,
|
WKC_CTRL = 0x4000,
|
||||||
WKC_ALT = 0x2000,
|
WKC_ALT = 0x2000,
|
||||||
WKC_META = 0x1000,
|
WKC_META = 0x1000,
|
||||||
|
|
||||||
// Special ones
|
// Special ones
|
||||||
WKC_NONE = 0,
|
WKC_NONE = 0,
|
||||||
WKC_ESC=1,
|
WKC_ESC=1,
|
||||||
|
@ -88,7 +88,7 @@ enum WindowKeyCodes {
|
||||||
// Return & tab
|
// Return & tab
|
||||||
WKC_RETURN = 13,
|
WKC_RETURN = 13,
|
||||||
WKC_TAB = 14,
|
WKC_TAB = 14,
|
||||||
|
|
||||||
// Numerical keyboard
|
// Numerical keyboard
|
||||||
WKC_NUM_0 = 16,
|
WKC_NUM_0 = 16,
|
||||||
WKC_NUM_1 = 17,
|
WKC_NUM_1 = 17,
|
||||||
|
@ -128,14 +128,14 @@ enum WindowKeyCodes {
|
||||||
// we only store this key here, no matter what character is really mapped to it
|
// we only store this key here, no matter what character is really mapped to it
|
||||||
// on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °)
|
// on a particular keyboard. (US keyboard: ` and ~ ; German keyboard: ^ and °)
|
||||||
WKC_BACKQUOTE = 45,
|
WKC_BACKQUOTE = 45,
|
||||||
|
|
||||||
// 0-9 are mapped to 48-57
|
// 0-9 are mapped to 48-57
|
||||||
// A-Z are mapped to 65-90
|
// A-Z are mapped to 65-90
|
||||||
// a-z are mapped to 97-122
|
// a-z are mapped to 97-122
|
||||||
|
|
||||||
|
|
||||||
//WKC_UNKNOWN = 0xFF,
|
//WKC_UNKNOWN = 0xFF,
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct WindowDesc {
|
typedef struct WindowDesc {
|
||||||
|
@ -161,7 +161,22 @@ enum {
|
||||||
WDP_CENTER = -2,
|
WDP_CENTER = -2,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
StringID caption;
|
||||||
|
bool caret;
|
||||||
|
WindowClass wnd_class;
|
||||||
|
WindowNumber wnd_num;
|
||||||
|
uint16 maxlen, maxwidth;
|
||||||
|
byte *buf;
|
||||||
|
} querystr_d;
|
||||||
|
|
||||||
#define WP(ptr,str) (*(str*)(ptr)->custom)
|
#define WP(ptr,str) (*(str*)(ptr)->custom)
|
||||||
|
// querystr_d is the bigest struct that comes in w->custom
|
||||||
|
// because 64-bit systems use 64-bit pointers, it is bigger on a 64-bit system
|
||||||
|
// then on a 32-bit system. Therefor the size is calculated from querystr_d
|
||||||
|
// instead of a hardcoded number.
|
||||||
|
// if any struct becomes bigger the querystr_d, it should be replaced.
|
||||||
|
#define WINDOW_CUSTOM_SIZE sizeof(querystr_d)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint16 count, cap, pos;
|
uint16 count, cap, pos;
|
||||||
|
@ -186,7 +201,7 @@ struct Window {
|
||||||
//const WindowDesc *desc;
|
//const WindowDesc *desc;
|
||||||
uint32 desc_flags;
|
uint32 desc_flags;
|
||||||
|
|
||||||
byte custom[16];
|
byte custom[WINDOW_CUSTOM_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -242,7 +257,7 @@ typedef struct {
|
||||||
} traindetails_d;
|
} traindetails_d;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int16 scroll_x, scroll_y, subscroll;
|
int16 scroll_x, scroll_y, subscroll;
|
||||||
} smallmap_d;
|
} smallmap_d;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -250,15 +265,6 @@ typedef struct {
|
||||||
byte gender;
|
byte gender;
|
||||||
} facesel_d;
|
} facesel_d;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
StringID caption;
|
|
||||||
bool caret;
|
|
||||||
WindowClass wnd_class;
|
|
||||||
WindowNumber wnd_num;
|
|
||||||
uint16 maxlen, maxwidth;
|
|
||||||
byte *buf;
|
|
||||||
} querystr_d;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int sel;
|
int sel;
|
||||||
byte cargo;
|
byte cargo;
|
||||||
|
@ -308,7 +314,7 @@ enum WindowWidgetBehaviours {
|
||||||
|
|
||||||
enum WindowWidgetTypes {
|
enum WindowWidgetTypes {
|
||||||
WWT_EMPTY = 0,
|
WWT_EMPTY = 0,
|
||||||
|
|
||||||
WWT_IMGBTN = 1, /* button with image */
|
WWT_IMGBTN = 1, /* button with image */
|
||||||
WWT_PANEL = WWT_IMGBTN,
|
WWT_PANEL = WWT_IMGBTN,
|
||||||
WWT_PANEL_2 = 2,/* button with diff image when clicked */
|
WWT_PANEL_2 = 2,/* button with diff image when clicked */
|
||||||
|
@ -322,7 +328,7 @@ enum WindowWidgetTypes {
|
||||||
WWT_SCROLLBAR = 8,
|
WWT_SCROLLBAR = 8,
|
||||||
WWT_FRAME = 9, /* frame */
|
WWT_FRAME = 9, /* frame */
|
||||||
WWT_CAPTION = 10,
|
WWT_CAPTION = 10,
|
||||||
|
|
||||||
WWT_HSCROLLBAR = 11,
|
WWT_HSCROLLBAR = 11,
|
||||||
WWT_LAST = 12,
|
WWT_LAST = 12,
|
||||||
|
|
||||||
|
@ -375,7 +381,7 @@ Window *AllocateWindow(
|
||||||
int y,
|
int y,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget);
|
const Widget *widget);
|
||||||
|
|
||||||
|
@ -385,7 +391,7 @@ Window *AllocateWindowDescFront(const WindowDesc *desc, int value);
|
||||||
Window *AllocateWindowAutoPlace(
|
Window *AllocateWindowAutoPlace(
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget);
|
const Widget *widget);
|
||||||
|
|
||||||
|
@ -394,7 +400,7 @@ Window *AllocateWindowAutoPlace2(
|
||||||
WindowNumber exist_num,
|
WindowNumber exist_num,
|
||||||
int width,
|
int width,
|
||||||
int height,
|
int height,
|
||||||
WindowProc *proc,
|
WindowProc *proc,
|
||||||
WindowClass cls,
|
WindowClass cls,
|
||||||
const Widget *widget);
|
const Widget *widget);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue