478 int action_id; |
478 int action_id; |
479 |
479 |
480 |
480 |
481 if (index < 0) { |
481 if (index < 0) { |
482 Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
482 Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
483 if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
483 if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) |
484 index = WP(w,menu_d).sel_index; |
484 index = WP(w, menu_d).sel_index; |
485 } |
485 } |
486 |
486 |
487 action_id = WP(w,menu_d).action_id; |
487 action_id = WP(w, menu_d).action_id; |
488 DeleteWindow(w); |
488 DeleteWindow(w); |
489 |
489 |
490 if (index >= 0) { |
490 if (index >= 0) { |
491 assert((uint)index <= lengthof(_menu_clicked_procs)); |
491 assert((uint)index <= lengthof(_menu_clicked_procs)); |
492 _menu_clicked_procs[action_id](index); |
492 _menu_clicked_procs[action_id](index); |
496 } |
496 } |
497 |
497 |
498 case WE_POPUPMENU_OVER: { |
498 case WE_POPUPMENU_OVER: { |
499 int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
499 int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
500 |
500 |
501 if (index == -1 || index == WP(w,menu_d).sel_index) return; |
501 if (index == -1 || index == WP(w, menu_d).sel_index) return; |
502 |
502 |
503 WP(w,menu_d).sel_index = index; |
503 WP(w, menu_d).sel_index = index; |
504 SetWindowDirty(w); |
504 SetWindowDirty(w); |
505 return; |
505 return; |
506 } |
506 } |
507 } |
507 } |
508 } |
508 } |
536 static void UpdatePlayerMenuHeight(Window *w) |
536 static void UpdatePlayerMenuHeight(Window *w) |
537 { |
537 { |
538 byte num = ActivePlayerCount(); |
538 byte num = ActivePlayerCount(); |
539 |
539 |
540 /* Increase one to fit in PlayerList in the menu when in network */ |
540 /* Increase one to fit in PlayerList in the menu when in network */ |
541 if (_networking && WP(w,menu_d).main_button == 9) num++; |
541 if (_networking && WP(w, menu_d).main_button == 9) num++; |
542 |
542 |
543 if (WP(w,menu_d).item_count != num) { |
543 if (WP(w, menu_d).item_count != num) { |
544 WP(w,menu_d).item_count = num; |
544 WP(w, menu_d).item_count = num; |
545 SetWindowDirty(w); |
545 SetWindowDirty(w); |
546 num = num * 10 + 2; |
546 num = num * 10 + 2; |
547 w->height = num; |
547 w->height = num; |
548 w->widget[0].bottom = w->widget[0].top + num - 1; |
548 w->widget[0].bottom = w->widget[0].top + num - 1; |
549 SetWindowDirty(w); |
549 SetWindowDirty(w); |
563 UpdatePlayerMenuHeight(w); |
563 UpdatePlayerMenuHeight(w); |
564 DrawWindowWidgets(w); |
564 DrawWindowWidgets(w); |
565 |
565 |
566 x = 1; |
566 x = 1; |
567 y = 1; |
567 y = 1; |
568 sel = WP(w,menu_d).sel_index; |
568 sel = WP(w, menu_d).sel_index; |
569 chk = WP(w,menu_d).checked_items; // let this mean gray items. |
569 chk = WP(w, menu_d).checked_items; // let this mean gray items. |
570 |
570 |
571 /* 9 = playerlist */ |
571 /* 9 = playerlist */ |
572 if (_networking && WP(w,menu_d).main_button == 9) { |
572 if (_networking && WP(w, menu_d).main_button == 9) { |
573 if (sel == 0) { |
573 if (sel == 0) { |
574 GfxFillRect(x, y, x + 238, y + 9, 0); |
574 GfxFillRect(x, y, x + 238, y + 9, 0); |
575 } |
575 } |
576 DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING); |
576 DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING); |
577 y += 10; |
577 y += 10; |
601 break; |
601 break; |
602 } |
602 } |
603 |
603 |
604 case WE_DESTROY: { |
604 case WE_DESTROY: { |
605 Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
605 Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0); |
606 v->RaiseWidget(WP(w,menu_d).main_button); |
606 v->RaiseWidget(WP(w, menu_d).main_button); |
607 SetWindowDirty(v); |
607 SetWindowDirty(v); |
608 return; |
608 return; |
609 } |
609 } |
610 |
610 |
611 case WE_POPUPMENU_SELECT: { |
611 case WE_POPUPMENU_SELECT: { |
612 int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
612 int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
613 int action_id = WP(w,menu_d).action_id; |
613 int action_id = WP(w, menu_d).action_id; |
614 |
614 |
615 /* We have a new entry at the top of the list of menu 9 when networking |
615 /* We have a new entry at the top of the list of menu 9 when networking |
616 * so keep that in count */ |
616 * so keep that in count */ |
617 if (_networking && WP(w,menu_d).main_button == 9) { |
617 if (_networking && WP(w, menu_d).main_button == 9) { |
618 if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
618 if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
619 } else { |
619 } else { |
620 index = GetPlayerIndexFromMenu(index); |
620 index = GetPlayerIndexFromMenu(index); |
621 } |
621 } |
622 |
622 |
623 if (index < 0) { |
623 if (index < 0) { |
624 Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
624 Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0); |
625 if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w,menu_d).main_button) |
625 if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button) |
626 index = WP(w,menu_d).sel_index; |
626 index = WP(w, menu_d).sel_index; |
627 } |
627 } |
628 |
628 |
629 DeleteWindow(w); |
629 DeleteWindow(w); |
630 |
630 |
631 if (index >= 0) { |
631 if (index >= 0) { |
639 UpdatePlayerMenuHeight(w); |
639 UpdatePlayerMenuHeight(w); |
640 index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
640 index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y); |
641 |
641 |
642 /* We have a new entry at the top of the list of menu 9 when networking |
642 /* We have a new entry at the top of the list of menu 9 when networking |
643 * so keep that in count */ |
643 * so keep that in count */ |
644 if (_networking && WP(w,menu_d).main_button == 9) { |
644 if (_networking && WP(w, menu_d).main_button == 9) { |
645 if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
645 if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1; |
646 } else { |
646 } else { |
647 index = GetPlayerIndexFromMenu(index); |
647 index = GetPlayerIndexFromMenu(index); |
648 } |
648 } |
649 |
649 |
650 if (index == -1 || index == WP(w,menu_d).sel_index) return; |
650 if (index == -1 || index == WP(w, menu_d).sel_index) return; |
651 |
651 |
652 WP(w,menu_d).sel_index = index; |
652 WP(w, menu_d).sel_index = index; |
653 SetWindowDirty(w); |
653 SetWindowDirty(w); |
654 return; |
654 return; |
655 } |
655 } |
656 } |
656 } |
657 } |
657 } |
720 |
720 |
721 w = AllocateWindow(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets); |
721 w = AllocateWindow(x, 22, width, item_count * 10 + 2, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets); |
722 w->widget[0].bottom = item_count * 10 + 1; |
722 w->widget[0].bottom = item_count * 10 + 1; |
723 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
723 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
724 |
724 |
725 WP(w,menu_d).item_count = item_count; |
725 WP(w, menu_d).item_count = item_count; |
726 WP(w,menu_d).sel_index = 0; |
726 WP(w, menu_d).sel_index = 0; |
727 WP(w,menu_d).main_button = GB(parent_button, 0, 8); |
727 WP(w, menu_d).main_button = GB(parent_button, 0, 8); |
728 WP(w,menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; |
728 WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button; |
729 WP(w,menu_d).string_id = base_string; |
729 WP(w, menu_d).string_id = base_string; |
730 WP(w,menu_d).checked_items = 0; |
730 WP(w, menu_d).checked_items = 0; |
731 WP(w,menu_d).disabled_items = disabled_mask; |
731 WP(w, menu_d).disabled_items = disabled_mask; |
732 |
732 |
733 _popup_menu_active = true; |
733 _popup_menu_active = true; |
734 |
734 |
735 SndPlayFx(SND_15_BEEP); |
735 SndPlayFx(SND_15_BEEP); |
736 return w; |
736 return w; |
744 w->InvalidateWidget(main_button); |
744 w->InvalidateWidget(main_button); |
745 |
745 |
746 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
746 DeleteWindowById(WC_TOOLBAR_MENU, 0); |
747 w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
747 w = AllocateWindow(x, 0x16, 0xF1, 0x52, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets); |
748 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
748 w->flags4 &= ~WF_WHITE_BORDER_MASK; |
749 WP(w,menu_d).item_count = 0; |
749 WP(w, menu_d).item_count = 0; |
750 WP(w,menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
750 WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0); |
751 if (_networking && main_button == 9) { |
751 if (_networking && main_button == 9) { |
752 if (_local_player != PLAYER_SPECTATOR) { |
752 if (_local_player != PLAYER_SPECTATOR) { |
753 WP(w,menu_d).sel_index++; |
753 WP(w, menu_d).sel_index++; |
754 } else { |
754 } else { |
755 /* Select client list by default for spectators */ |
755 /* Select client list by default for spectators */ |
756 WP(w,menu_d).sel_index = 0; |
756 WP(w, menu_d).sel_index = 0; |
757 } |
757 } |
758 } |
758 } |
759 WP(w,menu_d).action_id = main_button; |
759 WP(w, menu_d).action_id = main_button; |
760 WP(w,menu_d).main_button = main_button; |
760 WP(w, menu_d).main_button = main_button; |
761 WP(w,menu_d).checked_items = gray; |
761 WP(w, menu_d).checked_items = gray; |
762 WP(w,menu_d).disabled_items = 0; |
762 WP(w, menu_d).disabled_items = 0; |
763 _popup_menu_active = true; |
763 _popup_menu_active = true; |
764 SndPlayFx(SND_15_BEEP); |
764 SndPlayFx(SND_15_BEEP); |
765 return w; |
765 return w; |
766 } |
766 } |
767 |
767 |
874 if (vp->zoom == ZOOM_LVL_MIN) return false; |
874 if (vp->zoom == ZOOM_LVL_MIN) return false; |
875 vp->zoom = (ZoomLevel)((byte)vp->zoom - 1); |
875 vp->zoom = (ZoomLevel)((byte)vp->zoom - 1); |
876 vp->virtual_width >>= 1; |
876 vp->virtual_width >>= 1; |
877 vp->virtual_height >>= 1; |
877 vp->virtual_height >>= 1; |
878 |
878 |
879 WP(w,vp_d).scrollpos_x += vp->virtual_width >> 1; |
879 WP(w, vp_d).scrollpos_x += vp->virtual_width >> 1; |
880 WP(w,vp_d).scrollpos_y += vp->virtual_height >> 1; |
880 WP(w, vp_d).scrollpos_y += vp->virtual_height >> 1; |
881 WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
881 WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
882 WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
882 WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
883 break; |
883 break; |
884 case ZOOM_OUT: |
884 case ZOOM_OUT: |
885 if (vp->zoom == ZOOM_LVL_MAX) return false; |
885 if (vp->zoom == ZOOM_LVL_MAX) return false; |
886 vp->zoom = (ZoomLevel)((byte)vp->zoom + 1); |
886 vp->zoom = (ZoomLevel)((byte)vp->zoom + 1); |
887 |
887 |
888 WP(w,vp_d).scrollpos_x -= vp->virtual_width >> 1; |
888 WP(w, vp_d).scrollpos_x -= vp->virtual_width >> 1; |
889 WP(w,vp_d).scrollpos_y -= vp->virtual_height >> 1; |
889 WP(w, vp_d).scrollpos_y -= vp->virtual_height >> 1; |
890 WP(w,vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
890 WP(w, vp_d).dest_scrollpos_x = WP(w,vp_d).scrollpos_x; |
891 WP(w,vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
891 WP(w, vp_d).dest_scrollpos_y = WP(w,vp_d).scrollpos_y; |
892 |
892 |
893 vp->virtual_width <<= 1; |
893 vp->virtual_width <<= 1; |
894 vp->virtual_height <<= 1; |
894 vp->virtual_height <<= 1; |
895 break; |
895 break; |
896 } |
896 } |
977 if (HasBit(_display_opt, DO_WAYPOINTS)) SetBit(x, 9); |
977 if (HasBit(_display_opt, DO_WAYPOINTS)) SetBit(x, 9); |
978 if (HasBit(_display_opt, DO_FULL_ANIMATION)) SetBit(x, 10); |
978 if (HasBit(_display_opt, DO_FULL_ANIMATION)) SetBit(x, 10); |
979 if (HasBit(_display_opt, DO_FULL_DETAIL)) SetBit(x, 11); |
979 if (HasBit(_display_opt, DO_FULL_DETAIL)) SetBit(x, 11); |
980 if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12); |
980 if (IsTransparencySet(TO_HOUSES) && IsTransparencySet(TO_TREES)) SetBit(x, 12); |
981 if (IsTransparencySet(TO_SIGNS)) SetBit(x, 13); |
981 if (IsTransparencySet(TO_SIGNS)) SetBit(x, 13); |
982 WP(w,menu_d).checked_items = x; |
982 WP(w, menu_d).checked_items = x; |
983 } |
983 } |
984 |
984 |
985 |
985 |
986 static void ToolbarScenSaveOrLoad(Window *w) |
986 static void ToolbarScenSaveOrLoad(Window *w) |
987 { |
987 { |
2083 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING); |
2083 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING); |
2084 } else if (_do_autosave) { |
2084 } else if (_do_autosave) { |
2085 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING); |
2085 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING); |
2086 } else if (_pause_game) { |
2086 } else if (_pause_game) { |
2087 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); |
2087 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING); |
2088 } else if (WP(w,def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { |
2088 } else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) { |
2089 /* Draw the scrolling news text */ |
2089 /* Draw the scrolling news text */ |
2090 if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w,def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) { |
2090 if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) { |
2091 WP(w,def_d).data_1 = -1280; |
2091 WP(w, def_d).data_1 = -1280; |
2092 if (p != NULL) { |
2092 if (p != NULL) { |
2093 /* This is the default text */ |
2093 /* This is the default text */ |
2094 SetDParam(0, p->index); |
2094 SetDParam(0, p->index); |
2095 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
2095 DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING); |
2096 } |
2096 } |
2400 |
2400 |
2401 _main_status_desc.top = _screen.height - 12; |
2401 _main_status_desc.top = _screen.height - 12; |
2402 w = AllocateWindowDesc(&_main_status_desc); |
2402 w = AllocateWindowDesc(&_main_status_desc); |
2403 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2403 CLRBITS(w->flags4, WF_WHITE_BORDER_MASK); |
2404 |
2404 |
2405 WP(w,def_d).data_1 = -1280; |
2405 WP(w, def_d).data_1 = -1280; |
2406 } |
2406 } |
2407 |
2407 |
2408 void GameSizeChanged() |
2408 void GameSizeChanged() |
2409 { |
2409 { |
2410 _cur_resolution[0] = _screen.width; |
2410 _cur_resolution[0] = _screen.width; |