615 PopupMainToolbMenu(w, 66, 3, STR_015C_SAVE_GAME, 4); |
616 PopupMainToolbMenu(w, 66, 3, STR_015C_SAVE_GAME, 4); |
616 } |
617 } |
617 |
618 |
618 static void ToolbarMapClick(Window *w) |
619 static void ToolbarMapClick(Window *w) |
619 { |
620 { |
620 PopupMainToolbMenu(w, 96, 4, STR_02DE_MAP_OF_WORLD, 1); |
621 PopupMainToolbMenu(w, 96, 4, STR_02DE_MAP_OF_WORLD, 2); |
621 } |
622 } |
622 |
623 |
623 static void ToolbarTownClick(Window *w) |
624 static void ToolbarTownClick(Window *w) |
624 { |
625 { |
625 PopupMainToolbMenu(w, 118, 5, STR_02BB_TOWN_DIRECTORY, 1); |
626 PopupMainToolbMenu(w, 118, 5, STR_02BB_TOWN_DIRECTORY, 1); |
694 FOR_ALL_VEHICLES(v) |
695 FOR_ALL_VEHICLES(v) |
695 if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner); |
696 if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner); |
696 PopupMainPlayerToolbMenu(w, 376, 16, dis); |
697 PopupMainPlayerToolbMenu(w, 376, 16, dis); |
697 } |
698 } |
698 |
699 |
699 bool DoZoomInOut(int how) |
700 /* Zooms a viewport in a window in or out */ |
|
701 /* No button handling or what so ever */ |
|
702 bool DoZoomInOutWindow(int how, Window *w) |
700 { |
703 { |
701 ViewPort *vp; |
704 ViewPort *vp; |
702 Window *w, *wt; |
|
703 int button; |
705 int button; |
704 |
706 |
705 switch(_game_mode) { |
707 switch(_game_mode) { |
706 case GM_EDITOR: button = 9; break; |
708 case GM_EDITOR: button = 9; break; |
707 case GM_NORMAL: button = 17; break; |
709 case GM_NORMAL: button = 17; break; |
708 default: return false; |
710 default: return false; |
709 } |
711 } |
710 |
712 |
711 w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
712 assert(w); |
713 assert(w); |
713 vp = w->viewport; |
714 vp = w->viewport; |
714 |
|
715 wt = FindWindowById(WC_MAIN_TOOLBAR, 0); |
|
716 assert(wt); |
|
717 |
715 |
718 if (how == ZOOM_IN) { |
716 if (how == ZOOM_IN) { |
719 if (vp->zoom == 0) return false; |
717 if (vp->zoom == 0) return false; |
720 vp->zoom--; |
718 vp->zoom--; |
721 vp->virtual_width >>= 1; |
719 vp->virtual_width >>= 1; |
736 vp->virtual_height <<= 1; |
734 vp->virtual_height <<= 1; |
737 |
735 |
738 SetWindowDirty(w); |
736 SetWindowDirty(w); |
739 } |
737 } |
740 |
738 |
741 // update the toolbar button too |
739 // routine to disable/enable the zoom buttons. Didn't know where to place these otherwise |
742 CLRBIT(wt->disabled_state, button); |
740 { |
743 CLRBIT(wt->disabled_state, button + 1); |
741 Window * wt; |
744 if (vp->zoom == 0) SETBIT(wt->disabled_state, button); |
742 switch (w->window_class) { |
745 else if (vp->zoom == 2) SETBIT(wt->disabled_state, button + 1); |
743 case WC_MAIN_WINDOW: |
746 SetWindowDirty(wt); |
744 wt = FindWindowById(WC_MAIN_TOOLBAR, 0); |
747 |
745 break; |
|
746 case WC_EXTRA_VIEW_PORT: |
|
747 wt = FindWindowById(WC_EXTRA_VIEW_PORT, w->window_number); |
|
748 button = 4; |
|
749 break; |
|
750 } |
|
751 |
|
752 assert(wt); |
|
753 |
|
754 // update the toolbar button too |
|
755 CLRBIT(wt->disabled_state, button); |
|
756 CLRBIT(wt->disabled_state, button + 1); |
|
757 if (vp->zoom == 0) SETBIT(wt->disabled_state, button); |
|
758 else if (vp->zoom == 2) SETBIT(wt->disabled_state, button + 1); |
|
759 SetWindowDirty(wt); |
|
760 } |
|
761 |
748 return true; |
762 return true; |
749 } |
763 } |
750 |
764 |
751 static void MaxZoomIn() |
765 static void MaxZoomIn() |
752 { |
766 { |
753 while (DoZoomInOut(ZOOM_IN)) {} |
767 while (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0) ) ) {} |
754 } |
768 } |
755 |
769 |
756 static void ToolbarZoomInClick(Window *w) |
770 static void ToolbarZoomInClick(Window *w) |
757 { |
771 { |
758 if (DoZoomInOut(ZOOM_IN)) { |
772 if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
759 HandleButtonClick(w, 17); |
773 HandleButtonClick(w, 17); |
760 SndPlayFx(0x13); |
774 SndPlayFx(0x13); |
761 } |
775 } |
762 } |
776 } |
763 |
777 |
764 static void ToolbarZoomOutClick(Window *w) |
778 static void ToolbarZoomOutClick(Window *w) |
765 { |
779 { |
766 if (DoZoomInOut(ZOOM_OUT)) { |
780 if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) { |
767 HandleButtonClick(w, 18); |
781 HandleButtonClick(w, 18); |
768 SndPlayFx(0x13); |
782 SndPlayFx(0x13); |
769 } |
783 } |
770 } |
784 } |
771 |
785 |
868 PopupMainToolbMenu(w, 0x16A, 8 | (17<<8), STR_02DE_MAP_OF_WORLD, 2); |
882 PopupMainToolbMenu(w, 0x16A, 8 | (17<<8), STR_02DE_MAP_OF_WORLD, 2); |
869 } |
883 } |
870 |
884 |
871 static void ToolbarScenZoomIn(Window *w) |
885 static void ToolbarScenZoomIn(Window *w) |
872 { |
886 { |
873 if (DoZoomInOut(ZOOM_IN)) { |
887 if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) { |
874 HandleButtonClick(w, 9); |
888 HandleButtonClick(w, 9); |
875 SndPlayFx(0x13); |
889 SndPlayFx(0x13); |
876 } |
890 } |
877 } |
891 } |
878 |
892 |
879 static void ToolbarScenZoomOut(Window *w) |
893 static void ToolbarScenZoomOut(Window *w) |
880 { |
894 { |
881 if (DoZoomInOut(ZOOM_OUT)) { |
895 if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) { |
882 HandleButtonClick(w, 10); |
896 HandleButtonClick(w, 10); |
883 SndPlayFx(0x13); |
897 SndPlayFx(0x13); |
884 } |
898 } |
885 } |
899 } |
886 |
900 |
887 void ZoomInOrOutToCursor(bool in) |
901 void ZoomInOrOutToCursorWindow(bool in, Window *w) |
888 { |
902 { |
|
903 ViewPort * vp; |
889 Point pt; |
904 Point pt; |
890 Window* w; |
905 |
891 ViewPort* vp; |
|
892 |
|
893 w = FindWindowById(WC_MAIN_WINDOW, 0); |
|
894 assert(w != 0); |
906 assert(w != 0); |
895 |
907 |
896 vp = w->viewport; |
908 vp = w->viewport; |
897 |
909 |
898 if (_game_mode != GM_MENU) { |
910 if (_game_mode != GM_MENU) { |
899 if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
911 if ((in && vp->zoom == 0) || (!in && vp->zoom == 2)) |
900 return; |
912 return; |
901 |
913 |
902 pt = GetTileZoomCenter(in); |
914 pt = GetTileZoomCenterWindow(in,w); |
903 if (pt.x != -1) { |
915 if (pt.x != -1) { |
904 ScrollMainWindowTo(pt.x, pt.y); |
916 ScrollWindowTo(pt.x, pt.y, w); |
905 |
917 |
906 DoZoomInOut(in ? ZOOM_IN : ZOOM_OUT); |
918 DoZoomInOutWindow(in ? ZOOM_IN : ZOOM_OUT, w); |
907 } |
919 } |
908 } |
920 } |
909 } |
921 } |
910 |
922 |
911 void ResetLandscape() |
923 void ResetLandscape() |