src/toolbar_gui.cpp
changeset 9519 e75bc0300488
parent 9518 bc938928f466
child 9532 f44ff68484af
equal deleted inserted replaced
9518:bc938928f466 9519:e75bc0300488
    56 	TB_NORMAL,
    56 	TB_NORMAL,
    57 	TB_UPPER,
    57 	TB_UPPER,
    58 	TB_LOWER
    58 	TB_LOWER
    59 };
    59 };
    60 
    60 
       
    61 enum ToolbarScenEditorWidgets {
       
    62 	TBSE_PAUSE        = 0,
       
    63 	TBSE_FASTFORWARD,
       
    64 	TBSE_SPACERPANEL  = 4,
       
    65 	TBSE_DATEBACKWARD = 6,
       
    66 	TBSE_DATEFORWARD,
       
    67 	TBSE_ZOOMIN       = 9,
       
    68 	TBSE_ZOOMOUT,
       
    69 	TBSE_LANDGENERATE,
       
    70 	TBSE_TOWNGENERATE,
       
    71 	TBSE_INDUSTRYGENERATE,
       
    72 	TBSE_BUILDROAD,
       
    73 	TBSE_PLANTTREES,
       
    74 	TBSE_PLACESIGNS,
       
    75 };
       
    76 
    61 static ToolbarMode _toolbar_mode;
    77 static ToolbarMode _toolbar_mode;
    62 
    78 
    63 static void SelectSignTool()
    79 static void SelectSignTool()
    64 {
    80 {
    65 	if (_cursor.sprite == SPR_CURSOR_SIGN) {
    81 	if (_cursor.sprite == SPR_CURSOR_SIGN) {
   565 
   581 
   566 static void ToolbarScenDateBackward(Window *w)
   582 static void ToolbarScenDateBackward(Window *w)
   567 {
   583 {
   568 	/* don't allow too fast scrolling */
   584 	/* don't allow too fast scrolling */
   569 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
   585 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
   570 		w->HandleButtonClick(6);
   586 		w->HandleButtonClick(TBSE_DATEBACKWARD);
   571 		w->SetDirty();
   587 		w->SetDirty();
   572 
   588 
   573 		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
   589 		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year - 1, MIN_YEAR, MAX_YEAR);
   574 		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
   590 		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
   575 	}
   591 	}
   578 
   594 
   579 static void ToolbarScenDateForward(Window *w)
   595 static void ToolbarScenDateForward(Window *w)
   580 {
   596 {
   581 	/* don't allow too fast scrolling */
   597 	/* don't allow too fast scrolling */
   582 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
   598 	if ((w->flags4 & WF_TIMEOUT_MASK) <= 2 << WF_TIMEOUT_SHL) {
   583 		w->HandleButtonClick(7);
   599 		w->HandleButtonClick(TBSE_DATEFORWARD);
   584 		w->SetDirty();
   600 		w->SetDirty();
   585 
   601 
   586 		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
   602 		_settings_newgame.game_creation.starting_year = Clamp(_settings_newgame.game_creation.starting_year + 1, MIN_YEAR, MAX_YEAR);
   587 		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
   603 		SetDate(ConvertYMDToDate(_settings_newgame.game_creation.starting_year, 0, 1));
   588 	}
   604 	}
   596 }
   612 }
   597 
   613 
   598 static void ToolbarScenZoomIn(Window *w)
   614 static void ToolbarScenZoomIn(Window *w)
   599 {
   615 {
   600 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
   616 	if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
   601 		w->HandleButtonClick(9);
   617 		w->HandleButtonClick(TBSE_ZOOMIN);
   602 		SndPlayFx(SND_15_BEEP);
   618 		SndPlayFx(SND_15_BEEP);
   603 	}
   619 	}
   604 }
   620 }
   605 
   621 
   606 static void ToolbarScenZoomOut(Window *w)
   622 static void ToolbarScenZoomOut(Window *w)
   607 {
   623 {
   608 	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
   624 	if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
   609 		w->HandleButtonClick(10);
   625 		w->HandleButtonClick(TBSE_ZOOMOUT);
   610 		SndPlayFx(SND_15_BEEP);
   626 		SndPlayFx(SND_15_BEEP);
   611 	}
   627 	}
   612 }
   628 }
   613 
   629 
   614 static void ToolbarScenGenLand(Window *w)
   630 static void ToolbarScenGenLand(Window *w)
   615 {
   631 {
   616 	w->HandleButtonClick(11);
   632 	w->HandleButtonClick(TBSE_LANDGENERATE);
   617 	SndPlayFx(SND_15_BEEP);
   633 	SndPlayFx(SND_15_BEEP);
   618 
   634 
   619 	ShowEditorTerraformToolbar();
   635 	ShowEditorTerraformToolbar();
   620 }
   636 }
   621 
   637 
   622 
   638 
   623 static void ToolbarScenGenTown(Window *w)
   639 static void ToolbarScenGenTown(Window *w)
   624 {
   640 {
   625 	w->HandleButtonClick(12);
   641 	w->HandleButtonClick(TBSE_TOWNGENERATE);
   626 	SndPlayFx(SND_15_BEEP);
   642 	SndPlayFx(SND_15_BEEP);
   627 	ShowBuildTownWindow();
   643 	ShowBuildTownWindow();
   628 }
   644 }
   629 
   645 
   630 static void ToolbarScenGenIndustry(Window *w)
   646 static void ToolbarScenGenIndustry(Window *w)
   631 {
   647 {
   632 	w->HandleButtonClick(13);
   648 	w->HandleButtonClick(TBSE_INDUSTRYGENERATE);
   633 	SndPlayFx(SND_15_BEEP);
   649 	SndPlayFx(SND_15_BEEP);
   634 	ShowBuildIndustryWindow();
   650 	ShowBuildIndustryWindow();
   635 }
   651 }
   636 
   652 
   637 static void ToolbarScenBuildRoad(Window *w)
   653 static void ToolbarScenBuildRoad(Window *w)
   638 {
   654 {
   639 	w->HandleButtonClick(14);
   655 	w->HandleButtonClick(TBSE_BUILDROAD);
   640 	SndPlayFx(SND_15_BEEP);
   656 	SndPlayFx(SND_15_BEEP);
   641 	ShowBuildRoadScenToolbar();
   657 	ShowBuildRoadScenToolbar();
   642 }
   658 }
   643 
   659 
   644 static void ToolbarScenPlantTrees(Window *w)
   660 static void ToolbarScenPlantTrees(Window *w)
   645 {
   661 {
   646 	w->HandleButtonClick(15);
   662 	w->HandleButtonClick(TBSE_PLANTTREES);
   647 	SndPlayFx(SND_15_BEEP);
   663 	SndPlayFx(SND_15_BEEP);
   648 	ShowBuildTreesToolbar();
   664 	ShowBuildTreesToolbar();
   649 }
   665 }
   650 
   666 
   651 static void ToolbarScenPlaceSign(Window *w)
   667 static void ToolbarScenPlaceSign(Window *w)
   652 {
   668 {
   653 	w->HandleButtonClick(16);
   669 	w->HandleButtonClick(TBSE_PLACESIGNS);
   654 	SndPlayFx(SND_15_BEEP);
   670 	SndPlayFx(SND_15_BEEP);
   655 	SelectSignTool();
   671 	SelectSignTool();
   656 }
   672 }
   657 
   673 
   658 static void ToolbarBtn_NULL(Window *w)
   674 static void ToolbarBtn_NULL(Window *w)
   981 	NULL,
   997 	NULL,
   982 	ToolbarHelpClick,
   998 	ToolbarHelpClick,
   983 };
   999 };
   984 
  1000 
   985 struct ScenarioEditorToolbarWindow : Window {
  1001 struct ScenarioEditorToolbarWindow : Window {
   986 private:
       
   987 	enum ToolbarScenEditorWidgets {
       
   988 		TBSE_PAUSE        = 0,
       
   989 		TBSE_FASTFORWARD,
       
   990 		TBSE_SPACERPANEL  = 4,
       
   991 		TBSE_DATEBACKWARD = 6,
       
   992 		TBSE_DATEFORWARD,
       
   993 		TBSE_ZOOMIN       = 9,
       
   994 		TBSE_ZOOMOUT,
       
   995 	};
       
   996 
       
   997 public:
  1002 public:
   998 	ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
  1003 	ScenarioEditorToolbarWindow(const WindowDesc *desc) : Window(desc)
   999 	{
  1004 	{
  1000 		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
  1005 		CLRBITS(this->flags4, WF_WHITE_BORDER_MASK);
  1001 
  1006