virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case WID_BT_TYPE_11: case WID_BT_TYPE_12: case WID_BT_TYPE_13: case WID_BT_TYPE_14: case WID_BT_TYPE_21: case WID_BT_TYPE_22: case WID_BT_TYPE_23: case WID_BT_TYPE_24: case WID_BT_TYPE_31: case WID_BT_TYPE_32: case WID_BT_TYPE_33: case WID_BT_TYPE_34: if (widget - WID_BT_TYPE_11 >= this->count) break; if (HandlePlacePushButton(this, widget, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = (TreeType)(this->base + widget - WID_BT_TYPE_11); } break; case WID_BT_TYPE_RANDOM: // tree of random type. if (HandlePlacePushButton(this, WID_BT_TYPE_RANDOM, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = TREE_INVALID; } break; case WID_BT_MANY_RANDOM: // place trees randomly over the landscape if (_settings_client.sound.confirm) SndPlayFx(SND_15_BEEP); PlaceTreesRandomly(); MarkWholeScreenDirty(); break; } }
/** * Place new trees. * * This function takes care of the selected tree placer algorithm and * place randomly the trees for a new game. */ void GenerateTrees() { uint i, total; if (_settings_game.game_creation.tree_placer == TP_NONE) return; switch (_settings_game.game_creation.tree_placer) { case TP_ORIGINAL: i = _settings_game.game_creation.landscape == LT_ARCTIC ? 15 : 6; break; case TP_IMPROVED: i = _settings_game.game_creation.landscape == LT_ARCTIC ? 4 : 2; break; default: NOT_REACHED(); } total = ScaleByMapSize(DEFAULT_TREE_STEPS); if (_settings_game.game_creation.landscape == LT_TROPIC) total += ScaleByMapSize(DEFAULT_RAINFOREST_TREE_STEPS); total *= i; uint num_groups = (_settings_game.game_creation.landscape != LT_TOYLAND) ? ScaleByMapSize(GB(Random(), 0, 5) + 25) : 0; total += num_groups * DEFAULT_TREE_STEPS; SetGeneratingWorldProgress(GWP_TREE, total); if (num_groups != 0) PlaceTreeGroups(num_groups); for (; i != 0; i--) { PlaceTreesRandomly(); } }
virtual void OnClick(Point pt, int widget, int click_count) { switch (widget) { case BTW_TYPE_11: case BTW_TYPE_12: case BTW_TYPE_13: case BTW_TYPE_14: case BTW_TYPE_21: case BTW_TYPE_22: case BTW_TYPE_23: case BTW_TYPE_24: case BTW_TYPE_31: case BTW_TYPE_32: case BTW_TYPE_33: case BTW_TYPE_34: if (widget - BTW_TYPE_11 >= this->count) break; if (HandlePlacePushButton(this, widget, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = (TreeType)(this->base + widget - BTW_TYPE_11); } break; case BTW_TYPE_RANDOM: // tree of random type. if (HandlePlacePushButton(this, BTW_TYPE_RANDOM, SPR_CURSOR_TREE, HT_RECT)) { this->tree_to_plant = TREE_INVALID; } break; case BTW_MANY_RANDOM: // place trees randomly over the landscape this->LowerWidget(BTW_MANY_RANDOM); this->flags4 |= WF_TIMEOUT_BEGIN; SndPlayFx(SND_15_BEEP); PlaceTreesRandomly(); MarkWholeScreenDirty(); break; } }