# HG changeset patch # User chillcore # Date 1423430735 -3600 # zo feb 08 22:25:35 2015 +0100 # Node ID 3a112fa300c7e566a64ce2554b104d2f103bf87c # Parent 57d01e891aafaae33c048ea60c97b09e452bc812 Fix: Coding style genworld gui diff -r 57d01e891aaf -r 3a112fa300c7 src/genworld_gui.cpp --- a/src/genworld_gui.cpp zo feb 08 21:05:48 2015 +0000 +++ b/src/genworld_gui.cpp zo feb 08 22:25:35 2015 +0100 @@ -44,8 +44,8 @@ }; /** - * Changes landscape type and sets genworld window dirty - * @param landscape new landscape type + * Changes landscape type and sets genworld window dirty. + * @param landscape new landscape type. */ void SetNewLandscapeType(byte landscape) { @@ -54,7 +54,7 @@ InvalidateWindowClassesData(WC_GENERATE_LANDSCAPE); } -/** Widgets of GenerateLandscapeWindow when generating world */ +/** Widgets of GenerateLandscapeWindow when generating world. */ static const NWidgetPart _nested_generate_landscape_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_BROWN), @@ -172,7 +172,7 @@ EndContainer(), }; -/** Widgets of GenerateLandscapeWindow when loading heightmap */ +/** Widgets of GenerateLandscapeWindow when loading heightmap. */ static const NWidgetPart _nested_heightmap_load_widgets[] = { /* Window header. */ NWidget(NWID_HORIZONTAL), @@ -263,7 +263,7 @@ DeleteAllNonVitalWindows(); ClearErrorMessages(); - /* Copy all XXX_newgame to XXX when coming from outside the editor */ + /* Copy all XXX_newgame to XXX when coming from outside the editor. */ MakeNewgameSettingsLive(); ResetGRFConfig(true); @@ -322,7 +322,7 @@ this->mode = (GenerateLandscapeWindowMode)this->window_number; - /* Disable town, industry and trees in SE */ + /* Disable town, industry and trees pulldown in Scenario Editor. */ this->SetWidgetDisabledState(WID_GL_TOWN_PULLDOWN, _game_mode == GM_EDITOR); this->SetWidgetDisabledState(WID_GL_INDUSTRY_PULLDOWN, _game_mode == GM_EDITOR); this->SetWidgetDisabledState(WID_GL_TREE_PULLDOWN, _game_mode == GM_EDITOR); @@ -395,13 +395,13 @@ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) { if (!gui_scope) return; - /* Update the climate buttons */ + /* Update the climate buttons. */ this->SetWidgetLoweredState(WID_GL_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE); this->SetWidgetLoweredState(WID_GL_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC); this->SetWidgetLoweredState(WID_GL_TROPICAL, _settings_newgame.game_creation.landscape == LT_TROPIC); this->SetWidgetLoweredState(WID_GL_TOYLAND, _settings_newgame.game_creation.landscape == LT_TOYLAND); - /* You can't select smoothness / non-water borders if not terragenesis */ + /* You can't select smoothness / non-water borders if not terragenesis. */ if (mode == GLWM_GENERATE) { this->SetWidgetDisabledState(WID_GL_SMOOTHNESS_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); this->SetWidgetDisabledState(WID_GL_VARIETY_PULLDOWN, _settings_newgame.game_creation.land_generator == 0); @@ -420,10 +420,10 @@ WID_GL_TERRAIN_PULLDOWN, WID_GL_WATER_PULLDOWN, WIDGET_LIST_END); } - /* Disable snowline if not arctic */ + /* Disable snowline if not arctic. */ this->SetWidgetDisabledState(WID_GL_SNOW_LEVEL_TEXT, _settings_newgame.game_creation.landscape != LT_ARCTIC); - /* Update availability of decreasing / increasing start date and snow level */ + /* Update availability of decreasing / increasing start date and snow level. */ this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_DOWN, _settings_newgame.construction.max_heightlevel <= MIN_MAX_HEIGHTLEVEL); this->SetWidgetDisabledState(WID_GL_MAX_HEIGHTLEVEL_UP, _settings_newgame.construction.max_heightlevel >= MAX_MAX_HEIGHTLEVEL); this->SetWidgetDisabledState(WID_GL_START_DATE_DOWN, _settings_newgame.game_creation.starting_year <= MIN_YEAR); @@ -537,23 +537,23 @@ SetNewLandscapeType(widget - WID_GL_TEMPERATE); break; - case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X + case WID_GL_MAPSIZE_X_PULLDOWN: // Mapsize X. ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_GL_MAPSIZE_X_PULLDOWN); break; - case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y + case WID_GL_MAPSIZE_Y_PULLDOWN: // Mapsize Y. ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_GL_MAPSIZE_Y_PULLDOWN); break; - case WID_GL_TOWN_PULLDOWN: // Number of towns + case WID_GL_TOWN_PULLDOWN: // Number of towns. ShowDropDownMenu(this, _num_towns, _settings_newgame.difficulty.number_towns, WID_GL_TOWN_PULLDOWN, 0, 0); break; - case WID_GL_INDUSTRY_PULLDOWN: // Number of industries + case WID_GL_INDUSTRY_PULLDOWN: // Number of industries. ShowDropDownMenu(this, _num_inds, _settings_newgame.difficulty.industry_density, WID_GL_INDUSTRY_PULLDOWN, 0, 0); break; - case WID_GL_GENERATE_BUTTON: { // Generate + case WID_GL_GENERATE_BUTTON: { // Generate. /* Get rotated map size. */ uint map_x; uint map_y; @@ -581,8 +581,8 @@ } case WID_GL_MAX_HEIGHTLEVEL_DOWN: - case WID_GL_MAX_HEIGHTLEVEL_UP: // Height level buttons - /* Don't allow too fast scrolling */ + case WID_GL_MAX_HEIGHTLEVEL_UP: // Height level buttons. + /* Don't allow too fast scrolling. */ if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { this->HandleButtonClick(widget); @@ -592,7 +592,7 @@ _left_button_clicked = false; break; - case WID_GL_MAX_HEIGHTLEVEL_TEXT: // Height level text + case WID_GL_MAX_HEIGHTLEVEL_TEXT: // Height level text. this->widget_id = WID_GL_MAX_HEIGHTLEVEL_TEXT; SetDParam(0, _settings_newgame.construction.max_heightlevel); ShowQueryString(STR_JUST_INT, STR_MAPGEN_MAX_HEIGHTLEVEL_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); @@ -600,8 +600,8 @@ case WID_GL_START_DATE_DOWN: - case WID_GL_START_DATE_UP: // Year buttons - /* Don't allow too fast scrolling */ + case WID_GL_START_DATE_UP: // Year buttons. + /* Don't allow too fast scrolling. */ if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { this->HandleButtonClick(widget); @@ -611,15 +611,15 @@ _left_button_clicked = false; break; - case WID_GL_START_DATE_TEXT: // Year text + case WID_GL_START_DATE_TEXT: // Year text. this->widget_id = WID_GL_START_DATE_TEXT; SetDParam(0, _settings_newgame.game_creation.starting_year); ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); break; case WID_GL_SNOW_LEVEL_DOWN: - case WID_GL_SNOW_LEVEL_UP: // Snow line buttons - /* Don't allow too fast scrolling */ + case WID_GL_SNOW_LEVEL_UP: // Snow line buttons. + /* Don't allow too fast scrolling. */ if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { this->HandleButtonClick(widget); @@ -629,30 +629,30 @@ _left_button_clicked = false; break; - case WID_GL_SNOW_LEVEL_TEXT: // Snow line text + case WID_GL_SNOW_LEVEL_TEXT: // Snow line text. this->widget_id = WID_GL_SNOW_LEVEL_TEXT; SetDParam(0, _settings_newgame.game_creation.snow_line_height); ShowQueryString(STR_JUST_INT, STR_MAPGEN_SNOW_LINE_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_ENABLE_DEFAULT); break; - case WID_GL_TREE_PULLDOWN: // Tree placer + case WID_GL_TREE_PULLDOWN: // Tree placer. ShowDropDownMenu(this, _tree_placer, _settings_newgame.game_creation.tree_placer, WID_GL_TREE_PULLDOWN, 0, 0); break; - case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator + case WID_GL_LANDSCAPE_PULLDOWN: // Landscape generator. ShowDropDownMenu(this, _landscape, _settings_newgame.game_creation.land_generator, WID_GL_LANDSCAPE_PULLDOWN, 0, 0); break; - case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation + case WID_GL_HEIGHTMAP_ROTATION_PULLDOWN: // Heightmap rotation. ShowDropDownMenu(this, _rotation, _settings_newgame.game_creation.heightmap_rotation, WID_GL_HEIGHTMAP_ROTATION_PULLDOWN, 0, 0); break; - case WID_GL_TERRAIN_PULLDOWN: // Terrain type + case WID_GL_TERRAIN_PULLDOWN: // Terrain type. /* For the original map generation only the first four are valid. */ ShowDropDownMenu(this, _elevations, _settings_newgame.difficulty.terrain_type, WID_GL_TERRAIN_PULLDOWN, 0, _settings_newgame.game_creation.land_generator == LG_ORIGINAL ? ~0xF : 0); break; - case WID_GL_WATER_PULLDOWN: { // Water quantity + case WID_GL_WATER_PULLDOWN: { // Water quantity. uint32 hidden_mask = 0; /* Disable custom water level when the original map generator is active. */ if (_settings_newgame.game_creation.land_generator == 0) { @@ -662,19 +662,19 @@ break; } - case WID_GL_RIVER_PULLDOWN: // Amount of rivers + case WID_GL_RIVER_PULLDOWN: // Amount of rivers. ShowDropDownMenu(this, _rivers, _settings_newgame.game_creation.amount_of_rivers, WID_GL_RIVER_PULLDOWN, 0, 0); break; - case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness + case WID_GL_SMOOTHNESS_PULLDOWN: // Map smoothness. ShowDropDownMenu(this, _smoothness, _settings_newgame.game_creation.tgen_smoothness, WID_GL_SMOOTHNESS_PULLDOWN, 0, 0); break; - case WID_GL_VARIETY_PULLDOWN: // Map variety + case WID_GL_VARIETY_PULLDOWN: // Map variety. ShowDropDownMenu(this, _variety, _settings_newgame.game_creation.variety, WID_GL_VARIETY_PULLDOWN, 0, 0); break; - /* Freetype map borders */ + /* Freeform map borders. */ case WID_GL_WATER_NW: _settings_newgame.game_creation.water_borders = ToggleBit(_settings_newgame.game_creation.water_borders, BORDER_NW); this->InvalidateData(); @@ -766,7 +766,7 @@ if (!StrEmpty(str)) { value = atoi(str); } else { - /* An empty string means revert to the default */ + /* An empty string means revert to the default. */ switch (this->widget_id) { case WID_GL_MAX_HEIGHTLEVEL_TEXT: value = DEF_MAX_HEIGHTLEVEL; break; case WID_GL_START_DATE_TEXT: value = DEF_START_YEAR; break; @@ -827,11 +827,11 @@ DeleteWindowByClass(WC_GENERATE_LANDSCAPE); - /* Generate a new seed when opening the window */ + /* Generate a new seed when opening the window. */ _settings_newgame.game_creation.generation_seed = InteractiveRandom(); if (mode == GLWM_HEIGHTMAP) { - /* If the function returns negative, it means there was a problem loading the heightmap */ + /* If the function returns negative, it means there was a problem loading the heightmap. */ if (!GetHeightmapDimensions(_file_to_saveload.name, &x, &y)) return; } @@ -871,7 +871,7 @@ */ void StartNewGameWithoutGUI(uint seed) { - /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed' */ + /* GenerateWorld takes care of the possible GENERATE_NEW_SEED value in 'seed'. */ _settings_newgame.game_creation.generation_seed = seed; StartGeneratingLandscape(GLWM_GENERATE); @@ -960,25 +960,25 @@ SetNewLandscapeType(widget - WID_CS_TEMPERATE); break; - case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X + case WID_CS_MAPSIZE_X_PULLDOWN: // Mapsize X. ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_x, WID_CS_MAPSIZE_X_PULLDOWN); break; - case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y + case WID_CS_MAPSIZE_Y_PULLDOWN: // Mapsize Y. ShowDropDownList(this, BuildMapsizeDropDown(), _settings_newgame.game_creation.map_y, WID_CS_MAPSIZE_Y_PULLDOWN); break; - case WID_CS_EMPTY_WORLD: // Empty world / flat world + case WID_CS_EMPTY_WORLD: // Empty world / flat world. StartGeneratingLandscape(GLWM_SCENARIO); break; - case WID_CS_RANDOM_WORLD: // Generate + case WID_CS_RANDOM_WORLD: // Generate. ShowGenerateLandscape(); break; case WID_CS_START_DATE_DOWN: - case WID_CS_START_DATE_UP: // Year buttons - /* Don't allow too fast scrolling */ + case WID_CS_START_DATE_UP: // Year buttons. + /* Don't allow too fast scrolling. */ if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { this->HandleButtonClick(widget); this->SetDirty(); @@ -988,15 +988,15 @@ _left_button_clicked = false; break; - case WID_CS_START_DATE_TEXT: // Year text + case WID_CS_START_DATE_TEXT: // Year text. this->widget_id = WID_CS_START_DATE_TEXT; SetDParam(0, _settings_newgame.game_creation.starting_year); ShowQueryString(STR_JUST_INT, STR_MAPGEN_START_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_NONE); break; case WID_CS_FLAT_LAND_HEIGHT_DOWN: - case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons - /* Don't allow too fast scrolling */ + case WID_CS_FLAT_LAND_HEIGHT_UP: // Height level buttons. + /* Don't allow too fast scrolling. */ if (!(this->flags & WF_TIMEOUT) || this->timeout_timer <= 1) { this->HandleButtonClick(widget); this->SetDirty(); @@ -1006,7 +1006,7 @@ _left_button_clicked = false; break; - case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text + case WID_CS_FLAT_LAND_HEIGHT_TEXT: // Height level text. this->widget_id = WID_CS_FLAT_LAND_HEIGHT_TEXT; SetDParam(0, _settings_newgame.game_creation.se_flat_world_height); ShowQueryString(STR_JUST_INT, STR_SE_MAPGEN_FLAT_WORLD_HEIGHT_QUERY_CAPT, 4, this, CS_NUMERAL, QSF_NONE); @@ -1076,7 +1076,7 @@ NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_EMPTY_WORLD), SetDataTip(STR_SE_MAPGEN_FLAT_WORLD, STR_SE_MAPGEN_FLAT_WORLD_TOOLTIP), SetFill(1, 1), NWidget(WWT_PUSHTXTBTN, COLOUR_GREEN, WID_CS_RANDOM_WORLD), SetDataTip(STR_SE_MAPGEN_RANDOM_LAND, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetFill(1, 1), EndContainer(), - /* Labels + setting drop-downs */ + /* Labels + setting drop-downs. */ NWidget(NWID_VERTICAL), SetPIP(10, 6, 10), /* Map size. */ NWidget(NWID_HORIZONTAL), @@ -1207,7 +1207,7 @@ case WID_GP_PROGRESS_BAR: { SetDParamMaxValue(0, 100); *size = GetStringBoundingBox(STR_GENERATION_PROGRESS); - /* We need some spacing for the 'border' */ + /* We need some spacing for the 'border'. */ size->height += 8; size->width += 8; break; @@ -1226,7 +1226,7 @@ { switch (widget) { case WID_GP_PROGRESS_BAR: - /* Draw the % complete with a bar and a text */ + /* Draw the % complete with a bar and a text. */ DrawFrameRect(r.left, r.top, r.right, r.bottom, COLOUR_GREY, FR_BORDERONLY); DrawFrameRect(r.left + 1, r.top + 1, (int)((r.right - r.left - 2) * _gws.percent / 100) + r.left + 1, r.bottom - 1, COLOUR_MAUVE, FR_NONE); SetDParam(0, _gws.percent); @@ -1234,10 +1234,10 @@ break; case WID_GP_PROGRESS_TEXT: - /* Tell which class we are generating */ + /* Tell which class we are generating. */ DrawString(r.left, r.right, r.top, _gws.cls, TC_FROMSTRING, SA_HOR_CENTER); - /* And say where we are in that class */ + /* And say where we are in that class. */ SetDParam(0, _gws.current); SetDParam(1, _gws.total); DrawString(r.left, r.right, r.top + FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL, STR_GENERATION_PROGRESS_NUM, TC_FROMSTRING, SA_HOR_CENTER); @@ -1254,7 +1254,7 @@ _gws.current = 0; _gws.total = 0; _gws.percent = 0; - _gws.timer = 0; // Forces to paint the progress window immediately + _gws.timer = 0; // Forces to paint the progress window immediately. } /** @@ -1272,7 +1272,7 @@ assert_compile(lengthof(percent_table) == GWP_CLASS_COUNT + 1); assert(cls < GWP_CLASS_COUNT); - /* Do not run this function if we aren't in a thread */ + /* Do not run this function if we aren't in a thread. */ if (!IsGenerateWorldThreaded() && !_network_dedicated) return; if (IsGeneratingWorldAborted()) HandleGeneratingWorldAbortion(); @@ -1288,28 +1288,28 @@ _gws.percent = percent_table[cls]; } - /* Don't update the screen too often. So update it once in every once in a while... */ + /* Don't update the screen too often. So update it once every once in a while. */ if (!_network_dedicated && _gws.timer != 0 && _realtime_tick - _gws.timer < MODAL_PROGRESS_REDRAW_TIMEOUT) return; - /* Percentage is about the number of completed tasks, so 'current - 1' */ + /* Percentage is about the number of completed tasks, so 'current - 1'. */ _gws.percent = percent_table[cls] + (percent_table[cls + 1] - percent_table[cls]) * (_gws.current == 0 ? 0 : _gws.current - 1) / _gws.total; if (_network_dedicated) { static uint last_percent = 0; - /* Never display 0% */ + /* Never display 0%. */ if (_gws.percent == 0) return; - /* Reset if percent is lower than the last recorded */ + /* Reset if percent is lower than the last recorded. */ if (_gws.percent < last_percent) last_percent = 0; - /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5% */ + /* Display every 5%, but 6% is also very valid.. just not smaller steps than 5%. */ if (_gws.percent % 5 != 0 && _gws.percent <= last_percent + 5) return; - /* Never show steps smaller than 2%, even if it is a mod 5% */ + /* Never show steps smaller than 2%, even if it is a mod 5%. */ if (_gws.percent <= last_percent + 2) return; DEBUG(net, 1, "Map generation percentage complete: %d", _gws.percent); last_percent = _gws.percent; - /* Don't continue as dedicated never has a thread running */ + /* Don't continue as dedicated never has a thread running. */ return; } @@ -1319,7 +1319,7 @@ /* Release the rights to the map generator, and acquire the rights to the * paint thread. The 'other' thread already has the paint thread rights so * this ensures us that we are waiting until the paint thread is done - * before we reacquire the mapgen rights */ + * before we reacquire the mapgen rights. */ _modal_progress_work_mutex->EndCritical(); _modal_progress_paint_mutex->BeginCritical(); _modal_progress_work_mutex->BeginCritical(); @@ -1352,6 +1352,6 @@ */ void IncreaseGeneratingWorldProgress(GenWorldProgress cls) { - /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around */ + /* In fact the param 'class' isn't needed.. but for some security reasons, we want it around. */ _SetGeneratingWorldProgress(cls, 1, 0); }