Loading

Paste #pquxtgg4d

  1. Index: src/ai/ai_gui.cpp
  2. ===================================================================
  3. --- src/ai/ai_gui.cpp   (revision 27553)
  4. +++ src/ai/ai_gui.cpp   (working copy)
  5. @@ -675,8 +675,7 @@
  6.         EndContainer(),
  7.         NWidget(WWT_FRAME, COLOUR_MAUVE), SetDataTip(STR_AI_CONFIG_AI, STR_NULL), SetPadding(0, 5, 0, 5),
  8.             NWidget(NWID_HORIZONTAL),
  9. -               NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIC_LIST), SetMinimalSize(288, 112), SetFill(1, 0), SetMatrixDataTip(1, 8, STR_AI_CONFIG_AILIST_TOOLTIP), SetScrollbar(WID_AIC_SCROLLBAR),
  10. -               NWidget(NWID_VSCROLLBAR, COLOUR_MAUVE, WID_AIC_SCROLLBAR),
  11. +               NWidget(WWT_MATRIX, COLOUR_MAUVE, WID_AIC_LIST), SetMinimalSize(288, 210), SetFill(1, 0), SetMatrixDataTip(1, 15, STR_AI_CONFIG_AILIST_TOOLTIP),
  12.             EndContainer(),
  13.         EndContainer(),
  14.         NWidget(NWID_SPACER), SetMinimalSize(0, 9),
  15. @@ -711,16 +710,11 @@
  16.  struct AIConfigWindow : public Window {
  17.     CompanyID selected_slot; ///< The currently selected AI slot or \c INVALID_COMPANY.
  18.     int line_height;         ///< Height of a single AI-name line.
  19. -   Scrollbar *vscroll;      ///< Cache of the vertical scrollbar.
  20.  
  21.     AIConfigWindow() : Window(&_ai_config_desc)
  22.     {
  23.         this->InitNested(WN_GAME_OPTIONS_AI); // Initializes 'this->line_height' as a side effect.
  24. -       this->vscroll = this->GetScrollbar(WID_AIC_SCROLLBAR);
  25.         this->selected_slot = INVALID_COMPANY;
  26. -       NWidgetCore *nwi = this->GetWidget<NWidgetCore>(WID_AIC_LIST);
  27. -       this->vscroll->SetCapacity(nwi->current_y / this->line_height);
  28. -       this->vscroll->SetCount(MAX_COMPANIES);
  29.         this->OnInvalidateData(0);
  30.     }
  31.  
  32. @@ -764,7 +758,7 @@
  33.  
  34.             case WID_AIC_LIST:
  35.                 this->line_height = FONT_HEIGHT_NORMAL + WD_MATRIX_TOP + WD_MATRIX_BOTTOM;
  36. -               size->height = 8 * this->line_height;
  37. +               size->height = 15 * this->line_height;
  38.                 break;
  39.         }
  40.     }
  41. @@ -809,7 +803,7 @@
  42.  
  43.             case WID_AIC_LIST: {
  44.                 int y = r.top;
  45. -               for (int i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < MAX_COMPANIES; i++) {
  46. +               for (int i = 0; i < MAX_COMPANIES; i++) {
  47.                     StringID text;
  48.  
  49.                     if ((_game_mode != GM_NORMAL && i == 0) || (_game_mode == GM_NORMAL && Company::IsValidHumanID(i))) {
  50. @@ -860,7 +854,7 @@
  51.             }
  52.  
  53.             case WID_AIC_LIST: { // Select a slot
  54. -               this->selected_slot = (CompanyID)this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget, 0, this->line_height);
  55. +               this->selected_slot = (CompanyID)this->GetRowFromWidget(pt.y, widget, 0, this->line_height);
  56.                 this->InvalidateData();
  57.                 if (click_count > 1 && this->selected_slot != INVALID_COMPANY) ShowAIListWindow((CompanyID)this->selected_slot);
  58.                 break;
  59. @@ -870,7 +864,6 @@
  60.                 if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot - 1))) {
  61.                     Swap(GetGameSettings().ai_config[this->selected_slot], GetGameSettings().ai_config[this->selected_slot - 1]);
  62.                     this->selected_slot--;
  63. -                   this->vscroll->ScrollTowards(this->selected_slot);
  64.                     this->InvalidateData();
  65.                 }
  66.                 break;
  67. @@ -879,7 +872,6 @@
  68.                 if (IsEditable(this->selected_slot) && IsEditable((CompanyID)(this->selected_slot + 1))) {
  69.                     Swap(GetGameSettings().ai_config[this->selected_slot], GetGameSettings().ai_config[this->selected_slot + 1]);
  70.                     this->selected_slot++;
  71. -                   this->vscroll->ScrollTowards(this->selected_slot);
  72.                     this->InvalidateData();
  73.                 }
  74.                 break;
  75. Index: src/script/api/script_window.hpp
  76. ===================================================================
  77. --- src/script/api/script_window.hpp    (revision 27553)
  78. +++ src/script/api/script_window.hpp    (working copy)
  79. @@ -867,7 +867,6 @@
  80.         WID_AIC_NUMBER                               = ::WID_AIC_NUMBER,                               ///< Number of AIs.
  81.         WID_AIC_GAMELIST                             = ::WID_AIC_GAMELIST,                             ///< List with current selected GameScript.
  82.         WID_AIC_LIST                                 = ::WID_AIC_LIST,                                 ///< List with currently selected AIs.
  83. -       WID_AIC_SCROLLBAR                            = ::WID_AIC_SCROLLBAR,                            ///< Scrollbar to scroll through the selected AIs.
  84.         WID_AIC_MOVE_UP                              = ::WID_AIC_MOVE_UP,                              ///< Move up button.
  85.         WID_AIC_MOVE_DOWN                            = ::WID_AIC_MOVE_DOWN,                            ///< Move down button.
  86.         WID_AIC_CHANGE                               = ::WID_AIC_CHANGE,                               ///< Select another AI button.
  87. Index: src/widgets/ai_widget.h
  88. ===================================================================
  89. --- src/widgets/ai_widget.h (revision 27553)
  90. +++ src/widgets/ai_widget.h (working copy)
  91. @@ -42,7 +42,6 @@
  92.     WID_AIC_NUMBER,           ///< Number of AIs.
  93.     WID_AIC_GAMELIST,         ///< List with current selected GameScript.
  94.     WID_AIC_LIST,             ///< List with currently selected AIs.
  95. -   WID_AIC_SCROLLBAR,        ///< Scrollbar to scroll through the selected AIs.
  96.     WID_AIC_MOVE_UP,          ///< Move up button.
  97.     WID_AIC_MOVE_DOWN,        ///< Move down button.
  98.     WID_AIC_CHANGE,           ///< Select another AI button.

Comments