# object_gui.cpp

Go to the documentation of this file.

    00001 /* $Id: object_gui.cpp 26241 2014-01-12 18:00:39Z frosch $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #include "stdafx.h"
    00013 #include "command_func.h"
    00014 #include "newgrf.h"
    00015 #include "newgrf_object.h"
    00016 #include "newgrf_text.h"
    00017 #include "strings_func.h"
    00018 #include "viewport_func.h"
    00019 #include "window_gui.h"
    00020 #include "window_func.h"
    00021
    00022 #include "widgets/object_widget.h"
    00023
    00024 #include "table/strings.h"
    00025
    00026 static ObjectClassID _selected_object_class;
    00027 static int _selected_object_index;
    00028 static uint8 _selected_object_view;
    00029
    00031 class BuildObjectWindow : public PickerWindowBase {
    00032   static const int OBJECT_MARGIN = 4;
    00033   int line_height;
    00034   int info_height;
    00035   Scrollbar *vscroll;
    00036
    00038   void EnsureSelectedObjectClassIsVisible()
    00039   {
    00040     uint pos = 0;
    00041     for (int i = 0; i < _selected_object_class; i++) {
    00042       if (ObjectClass::Get((ObjectClassID) i)->GetUISpecCount() == 0) continue;
    00043       pos++;
    00044     }
    00045     this->vscroll->ScrollTowards(pos);
    00046   }
    00047
    00052   bool CanRestoreSelectedObject()
    00053   {
    00054     if (_selected_object_index == -1) return false;
    00055
    00056     ObjectClass *sel_objclass = ObjectClass::Get(_selected_object_class);
    00057     if ((int)sel_objclass->GetSpecCount() <= _selected_object_index) return false;
    00058
    00059     return sel_objclass->GetSpec(_selected_object_index)->IsAvailable();
    00060   }
    00061
    00066   uint GetMatrixColumnCount()
    00067   {
    00068     const NWidgetBase *matrix = this->GetWidget<NWidgetBase>(WID_BO_SELECT_MATRIX);
    00069     return 1 + (matrix->current_x - matrix->smallest_x) / matrix->resize_x;
    00070   }
    00071
    00072 public:
    00073   BuildObjectWindow(WindowDesc *desc, Window *w) : PickerWindowBase(desc, w), info_height(1)
    00074   {
    00075     this->CreateNestedTree();
    00076     this->vscroll = this->GetScrollbar(WID_BO_SCROLLBAR);
    00077     this->FinishInitNested(0);
    00078
    00079     this->vscroll->SetPosition(0);
    00080     this->vscroll->SetCount(ObjectClass::GetUIClassCount());
    00081
    00082     NWidgetMatrix *matrix = this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX);
    00083     matrix->SetScrollbar(this->GetScrollbar(WID_BO_SELECT_SCROLL));
    00084
    00085     this->SelectOtherClass(_selected_object_class);
    00086     if (this->CanRestoreSelectedObject()) {
    00087       this->SelectOtherObject(_selected_object_index);
    00088     } else {
    00089       this->SelectFirstAvailableObject(true);
    00090     }
    00091     assert(ObjectClass::Get(_selected_object_class)->GetUISpecCount() > 0); // object GUI should be disables elsewise
    00092     this->EnsureSelectedObjectClassIsVisible();
    00093     this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetCount(4);
    00094   }
    00095
    00096   virtual void SetStringParameters(int widget) const
    00097   {
    00098     switch (widget) {
    00099       case WID_BO_OBJECT_NAME: {
    00100         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00101         SetDParam(0, spec != NULL ? spec->name : STR_EMPTY);
    00102         break;
    00103       }
    00104
    00105       case WID_BO_OBJECT_SIZE: {
    00106         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00107         int size = spec == NULL ? 0 : spec->size;
    00108         SetDParam(0, GB(size, HasBit(_selected_object_view, 0) ? 4 : 0, 4));
    00109         SetDParam(1, GB(size, HasBit(_selected_object_view, 0) ? 0 : 4, 4));
    00110         break;
    00111       }
    00112
    00113       default: break;
    00114     }
    00115   }
    00116
    00117   virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
    00118   {
    00119     switch (widget) {
    00120       case WID_BO_CLASS_LIST: {
    00121         for (uint i = 0; i < ObjectClass::GetClassCount(); i++) {
    00122           ObjectClass *objclass = ObjectClass::Get((ObjectClassID)i);
    00123           if (objclass->GetUISpecCount() == 0) continue;
    00124           size->width = max(size->width, GetStringBoundingBox(objclass->name).width);
    00125         }
    00126         size->width += padding.width;
    00127         this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
    00128         resize->height = this->line_height;
    00129         size->height = 5 * this->line_height;
    00130         break;
    00131       }
    00132
    00133       case WID_BO_OBJECT_NAME:
    00134       case WID_BO_OBJECT_SIZE:
    00135         /* We do not want the window to resize when selecting objects; better clip texts */
    00136         size->width = 0;
    00137         break;
    00138
    00139       case WID_BO_OBJECT_MATRIX: {
    00140         /* Get the right amount of buttons based on the current spec. */
    00141         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00142         if (spec != NULL) {
    00143           if (spec->views >= 2) size->width  += resize->width;
    00144           if (spec->views >= 4) size->height += resize->height;
    00145         }
    00146         resize->width = 0;
    00147         resize->height = 0;
    00148         break;
    00149       }
    00150
    00151       case WID_BO_OBJECT_SPRITE: {
    00152         bool two_wide = false;  // Whether there will be two widgets next to each other in the matrix or not.
    00153         int height[2] = {0, 0}; // The height for the different views; in this case views 1/2 and 4.
    00154
    00155         /* Get the height and view information. */
    00156         for (int i = 0; i < NUM_OBJECTS; i++) {
    00157           const ObjectSpec *spec = ObjectSpec::Get(i);
    00158           if (!spec->IsEverAvailable()) continue;
    00159           two_wide |= spec->views >= 2;
    00160           height[spec->views / 4] = max<int>(ObjectSpec::Get(i)->height, height[spec->views / 4]);
    00161         }
    00162
    00163         /* Determine the pixel heights. */
    00164         for (size_t i = 0; i < lengthof(height); i++) {
    00165           height[i] *= TILE_HEIGHT;
    00166           height[i] += TILE_PIXELS + 2 * OBJECT_MARGIN;
    00167         }
    00168
    00169         /* Now determine the size of the minimum widgets. When there are two columns, then
    00170          * we want these columns to be slightly less wide. When there are two rows, then
    00171          * determine the size of the widgets based on the maximum size for a single row
    00172          * of widgets, or just the twice the widget height of the two row ones. */
    00173         size->height = max(height[0], height[1] * 2 + 2);
    00174         if (two_wide) {
    00175           size->width  = (3 * TILE_PIXELS + 2 * OBJECT_MARGIN) * 2 + 2;
    00176         } else {
    00177           size->width  = 4 * TILE_PIXELS + 2 * OBJECT_MARGIN;
    00178         }
    00179
    00180         /* Get the right size for the single widget based on the current spec. */
    00181         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00182         if (spec != NULL) {
    00183           if (spec->views >= 2) size->width  = size->width  / 2 - 1;
    00184           if (spec->views >= 4) size->height = size->height / 2 - 1;
    00185         }
    00186         break;
    00187       }
    00188
    00189       case WID_BO_INFO:
    00190         size->height = this->info_height;
    00191         break;
    00192
    00193       case WID_BO_SELECT_MATRIX:
    00194         fill->height = 1;
    00195         resize->height = 1;
    00196         break;
    00197
    00198       default: break;
    00199     }
    00200   }
    00201
    00202   virtual void DrawWidget(const Rect &r, int widget) const
    00203   {
    00204     switch (GB(widget, 0, 16)) {
    00205       case WID_BO_CLASS_LIST: {
    00206         int y = r.top;
    00207         uint pos = 0;
    00208         for (uint i = 0; i < ObjectClass::GetClassCount(); i++) {
    00209           ObjectClass *objclass = ObjectClass::Get((ObjectClassID)i);
    00210           if (objclass->GetUISpecCount() == 0) continue;
    00211           if (!this->vscroll->IsVisible(pos++)) continue;
    00212           SetDParam(0, objclass->name);
    00213           DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, STR_JUST_STRING,
    00214               ((int)i == _selected_object_class) ? TC_WHITE : TC_BLACK);
    00215           y += this->line_height;
    00216         }
    00217         break;
    00218       }
    00219
    00220       case WID_BO_OBJECT_SPRITE: {
    00221         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00222         if (spec == NULL) break;
    00223
    00224         /* Height of the selection matrix.
    00225          * Depending on the number of views, the matrix has a 1x1, 1x2, 2x1 or 2x2 layout. To make the previews
    00226          * look nice in all layouts, we use the 4x4 layout (smallest previews) as starting point. For the bigger
    00227          * previews in the layouts with less views we add space homogeneously on all sides, so the 4x4 preview-rectangle
    00228          * is centered in the 2x1, 1x2 resp. 1x1 buttons. */
    00229         uint matrix_height = this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->current_y;
    00230
    00231         DrawPixelInfo tmp_dpi;
    00232         /* Set up a clipping area for the preview. */
    00233         if (FillDrawPixelInfo(&tmp_dpi, r.left, r.top, r.right - r.left + 1, r.bottom - r.top + 1)) {
    00234           DrawPixelInfo *old_dpi = _cur_dpi;
    00235           _cur_dpi = &tmp_dpi;
    00236           if (spec->grf_prop.grffile == NULL) {
    00237             extern const DrawTileSprites _objects[];
    00238             const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
    00239             DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - TILE_PIXELS, dts, PAL_NONE);
    00240           } else {
    00241             DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, (r.bottom - r.top + matrix_height / 2) / 2 - OBJECT_MARGIN - TILE_PIXELS, spec, GB(widget, 16, 16));
    00242           }
    00243           _cur_dpi = old_dpi;
    00244         }
    00245         break;
    00246       }
    00247
    00248       case WID_BO_SELECT_IMAGE: {
    00249         ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
    00250         int obj_index = objclass->GetIndexFromUI(GB(widget, 16, 16));
    00251         if (obj_index < 0) break;
    00252         const ObjectSpec *spec = objclass->GetSpec(obj_index);
    00253         if (spec == NULL) break;
    00254
    00255         if (!spec->IsAvailable()) {
    00256           GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK, FILLRECT_CHECKER);
    00257         }
    00258         DrawPixelInfo tmp_dpi;
    00259         /* Set up a clipping area for the preview. */
    00260         if (FillDrawPixelInfo(&tmp_dpi, r.left + 1, r.top, (r.right - 1) - (r.left + 1) + 1, r.bottom - r.top + 1)) {
    00261           DrawPixelInfo *old_dpi = _cur_dpi;
    00262           _cur_dpi = &tmp_dpi;
    00263           if (spec->grf_prop.grffile == NULL) {
    00264             extern const DrawTileSprites _objects[];
    00265             const DrawTileSprites *dts = &_objects[spec->grf_prop.local_id];
    00266             DrawOrigTileSeqInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - TILE_PIXELS, dts, PAL_NONE);
    00267           } else {
    00268             DrawNewObjectTileInGUI((r.right - r.left) / 2 - 1, r.bottom - r.top - OBJECT_MARGIN - TILE_PIXELS, spec,
    00269                 min(_selected_object_view, spec->views - 1));
    00270           }
    00271           _cur_dpi = old_dpi;
    00272         }
    00273         break;
    00274       }
    00275
    00276       case WID_BO_INFO: {
    00277         const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00278         if (spec == NULL) break;
    00279
    00280         /* Get the extra message for the GUI */
    00281         if (HasBit(spec->callback_mask, CBM_OBJ_FUND_MORE_TEXT)) {
    00282           uint16 callback_res = GetObjectCallback(CBID_OBJECT_FUND_MORE_TEXT, 0, 0, spec, NULL, INVALID_TILE, _selected_object_view);
    00283           if (callback_res != CALLBACK_FAILED && callback_res != 0x400) {
    00284             if (callback_res > 0x400) {
    00285               ErrorUnknownCallbackResult(spec->grf_prop.grffile->grfid, CBID_OBJECT_FUND_MORE_TEXT, callback_res);
    00286             } else {
    00287               StringID message = GetGRFStringID(spec->grf_prop.grffile->grfid, 0xD000 + callback_res);
    00288               if (message != STR_NULL && message != STR_UNDEFINED) {
    00289                 StartTextRefStackUsage(spec->grf_prop.grffile, 6);
    00290                 /* Use all the available space left from where we stand up to the
    00291                  * end of the window. We ALSO enlarge the window if needed, so we
    00292                  * can 'go' wild with the bottom of the window. */
    00293                 int y = DrawStringMultiLine(r.left, r.right, r.top, UINT16_MAX, message, TC_ORANGE) - r.top;
    00294                 StopTextRefStackUsage();
    00295                 if (y > this->info_height) {
    00296                   BuildObjectWindow *bow = const_cast<BuildObjectWindow *>(this);
    00297                   bow->info_height = y + 2;
    00298                   bow->ReInit();
    00299                 }
    00300               }
    00301             }
    00302           }
    00303         }
    00304       }
    00305     }
    00306   }
    00307
    00312   void SelectOtherClass(ObjectClassID object_class_index)
    00313   {
    00314     _selected_object_class = object_class_index;
    00315     this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetCount(ObjectClass::Get(_selected_object_class)->GetUISpecCount());
    00316   }
    00317
    00322   void SelectOtherObject(int object_index)
    00323   {
    00324     _selected_object_index = object_index;
    00325     if (_selected_object_index != -1) {
    00326       const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00327       _selected_object_view = min(_selected_object_view, spec->views - 1);
    00328       this->ReInit();
    00329     } else {
    00330       _selected_object_view = 0;
    00331     }
    00332
    00333     this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(_selected_object_view);
    00334     this->GetWidget<NWidgetMatrix>(WID_BO_SELECT_MATRIX)->SetClicked(_selected_object_index != -1 ? ObjectClass::Get(_selected_object_class)->GetUIFromIndex(_selected_object_index) : -1);
    00335     this->UpdateSelectSize();
    00336     this->SetDirty();
    00337   }
    00338
    00339   void UpdateSelectSize()
    00340   {
    00341     if (_selected_object_index == -1) {
    00342       SetTileSelectSize(1, 1);
    00343     } else {
    00344       const ObjectSpec *spec = ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index);
    00345       int w = GB(spec->size, HasBit(_selected_object_view, 0) ? 4 : 0, 4);
    00346       int h = GB(spec->size, HasBit(_selected_object_view, 0) ? 0 : 4, 4);
    00347       SetTileSelectSize(w, h);
    00348     }
    00349   }
    00350
    00351   virtual void OnResize()
    00352   {
    00353     this->vscroll->SetCapacityFromWidget(this, WID_BO_CLASS_LIST);
    00354   }
    00355
    00356   virtual void OnClick(Point pt, int widget, int click_count)
    00357   {
    00358     switch (GB(widget, 0, 16)) {
    00359       case WID_BO_CLASS_LIST: {
    00360         int num_clicked = this->vscroll->GetPosition() + (pt.y - this->nested_array[widget]->pos_y) / this->line_height;
    00361         if (num_clicked >= (int)ObjectClass::GetUIClassCount()) break;
    00362
    00363         this->SelectOtherClass(ObjectClass::GetUIClass(num_clicked));
    00364         this->SelectFirstAvailableObject(false);
    00365         break;
    00366       }
    00367
    00368       case WID_BO_SELECT_IMAGE: {
    00369         ObjectClass *objclass = ObjectClass::Get(_selected_object_class);
    00370         int num_clicked = objclass->GetIndexFromUI(GB(widget, 16, 16));
    00371         if (num_clicked >= 0 && objclass->GetSpec(num_clicked)->IsAvailable()) this->SelectOtherObject(num_clicked);
    00372         break;
    00373       }
    00374
    00375       case WID_BO_OBJECT_SPRITE:
    00376         if (_selected_object_index != -1) {
    00377           _selected_object_view = GB(widget, 16, 16);
    00378           this->GetWidget<NWidgetMatrix>(WID_BO_OBJECT_MATRIX)->SetClicked(_selected_object_view);
    00379           this->UpdateSelectSize();
    00380           this->SetDirty();
    00381         }
    00382         break;
    00383     }
    00384   }
    00385
    00391   void SelectFirstAvailableObject(bool change_class)
    00392   {
    00393     /* First try to select an object in the selected class. */
    00394     ObjectClass *sel_objclass = ObjectClass::Get(_selected_object_class);
    00395     for (uint i = 0; i < sel_objclass->GetSpecCount(); i++) {
    00396       const ObjectSpec *spec = sel_objclass->GetSpec(i);
    00397       if (spec->IsAvailable()) {
    00398         this->SelectOtherObject(i);
    00399         return;
    00400       }
    00401     }
    00402     if (change_class) {
    00403       /* If that fails, select the first available object
    00404        * from a random class. */
    00405       for (ObjectClassID j = OBJECT_CLASS_BEGIN; j < OBJECT_CLASS_MAX; j++) {
    00406         ObjectClass *objclass = ObjectClass::Get(j);
    00407         for (uint i = 0; i < objclass->GetSpecCount(); i++) {
    00408           const ObjectSpec *spec = objclass->GetSpec(i);
    00409           if (spec->IsAvailable()) {
    00410             this->SelectOtherClass(j);
    00411             this->SelectOtherObject(i);
    00412             return;
    00413           }
    00414         }
    00415       }
    00416     }
    00417     /* If all objects are unavailable, select nothing... */
    00418     if (ObjectClass::Get(_selected_object_class)->GetUISpecCount() == 0) {
    00419       /* ... but make sure that the class is not empty. */
    00420       for (ObjectClassID j = OBJECT_CLASS_BEGIN; j < OBJECT_CLASS_MAX; j++) {
    00421         if (ObjectClass::Get(j)->GetUISpecCount() > 0) {
    00422           this->SelectOtherClass(j);
    00423           break;
    00424         }
    00425       }
    00426     }
    00427     this->SelectOtherObject(-1);
    00428   }
    00429 };
    00430
    00431 static const NWidgetPart _nested_build_object_widgets[] = {
    00432   NWidget(NWID_HORIZONTAL),
    00433     NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
    00434     NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_OBJECT_BUILD_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
    00435     NWidget(WWT_DEFSIZEBOX, COLOUR_DARK_GREEN),
    00436   EndContainer(),
    00437   NWidget(WWT_PANEL, COLOUR_DARK_GREEN),
    00438     NWidget(NWID_HORIZONTAL), SetPadding(2, 0, 0, 0),
    00439       NWidget(NWID_VERTICAL),
    00440         NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 2, 5),
    00441           NWidget(WWT_MATRIX, COLOUR_GREY, WID_BO_CLASS_LIST), SetFill(1, 0), SetMatrixDataTip(1, 0, STR_OBJECT_BUILD_CLASS_TOOLTIP), SetScrollbar(WID_BO_SCROLLBAR),
    00442           NWidget(NWID_VSCROLLBAR, COLOUR_GREY, WID_BO_SCROLLBAR),
    00443         EndContainer(),
    00444         NWidget(NWID_HORIZONTAL), SetPadding(0, 5, 0, 5),
    00445           NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_OBJECT_MATRIX), SetPIP(0, 2, 0),
    00446             NWidget(WWT_PANEL, COLOUR_GREY, WID_BO_OBJECT_SPRITE), SetDataTip(0x0, STR_OBJECT_BUILD_PREVIEW_TOOLTIP), EndContainer(),
    00447           EndContainer(),
    00448         EndContainer(),
    00449         NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_NAME), SetDataTip(STR_ORANGE_STRING, STR_NULL), SetPadding(2, 5, 2, 5),
    00450         NWidget(WWT_TEXT, COLOUR_DARK_GREEN, WID_BO_OBJECT_SIZE), SetDataTip(STR_OBJECT_BUILD_SIZE, STR_NULL), SetPadding(2, 5, 2, 5),
    00451       EndContainer(),
    00452       NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetScrollbar(WID_BO_SELECT_SCROLL),
    00453         NWidget(NWID_HORIZONTAL),
    00454           NWidget(NWID_MATRIX, COLOUR_DARK_GREEN, WID_BO_SELECT_MATRIX), SetFill(0, 1), SetPIP(0, 2, 0),
    00455             NWidget(WWT_PANEL, COLOUR_DARK_GREEN, WID_BO_SELECT_IMAGE), SetMinimalSize(66, 60), SetDataTip(0x0, STR_OBJECT_BUILD_TOOLTIP),
    00456                 SetFill(0, 0), SetResize(0, 0), SetScrollbar(WID_BO_SELECT_SCROLL),
    00457             EndContainer(),
    00458           EndContainer(),
    00459           NWidget(NWID_VSCROLLBAR, COLOUR_DARK_GREEN, WID_BO_SELECT_SCROLL),
    00460         EndContainer(),
    00461       EndContainer(),
    00462     EndContainer(),
    00463     NWidget(NWID_HORIZONTAL),
    00464       NWidget(WWT_EMPTY, INVALID_COLOUR, WID_BO_INFO), SetPadding(2, 5, 0, 5), SetFill(1, 0), SetResize(1, 0),
    00465       NWidget(NWID_VERTICAL),
    00466         NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(0, 1), EndContainer(),
    00467         NWidget(WWT_RESIZEBOX, COLOUR_DARK_GREEN),
    00468       EndContainer(),
    00469     EndContainer(),
    00470   EndContainer(),
    00471 };
    00472
    00473 static WindowDesc _build_object_desc(
    00474   WDP_AUTO, "build_object", 0, 0,
    00475   WC_BUILD_OBJECT, WC_BUILD_TOOLBAR,
    00476   WDF_CONSTRUCTION,
    00477   _nested_build_object_widgets, lengthof(_nested_build_object_widgets)
    00478 );
    00479
    00484 void ShowBuildObjectPicker(Window *w)
    00485 {
    00486   new BuildObjectWindow(&_build_object_desc, w);
    00487 }
    00488
    00490 void InitializeObjectGui()
    00491 {
    00492   _selected_object_class = (ObjectClassID)0;
    00493 }
    00494
    00500 void PlaceProc_Object(TileIndex tile)
    00501 {
    00502   DoCommandP(tile, ObjectClass::Get(_selected_object_class)->GetSpec(_selected_object_index)->Index(), _selected_object_view, CMD_BUILD_OBJECT | CMD_MSG(STR_ERROR_CAN_T_BUILD_OBJECT), CcTerraform);
    00503 }