Merge branch 'master' into jgrpp
# Conflicts: # .github/workflows/release-windows.yml # src/autoreplace_gui.cpp # src/cargotype.cpp # src/company_base.h # src/company_cmd.cpp # src/company_gui.cpp # src/currency.h # src/date_gui.cpp # src/dropdown.cpp # src/dropdown_func.h # src/dropdown_type.h # src/game/game_gui.cpp # src/genworld.cpp # src/genworld_gui.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/house.h # src/industry_gui.cpp # src/network/network_client.cpp # src/network/network_server.cpp # src/network/network_type.h # src/newgrf_class_func.h # src/newgrf_house.cpp # src/newgrf_roadstop.h # src/openttd.cpp # src/order_gui.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/screenshot_gui.cpp # src/settings_gui.cpp # src/settings_type.h # src/slider.cpp # src/smallmap_gui.cpp # src/station_cmd.cpp # src/stdafx.h # src/survey.cpp # src/tile_map.h # src/town_cmd.cpp # src/town_gui.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/vehicle_gui_base.h
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
#include "company_manager_face.h"
|
||||
#include "strings_func.h"
|
||||
#include "date_func.h"
|
||||
#include "widgets/dropdown_type.h"
|
||||
#include "dropdown_type.h"
|
||||
#include "tilehighlight_func.h"
|
||||
#include "company_base.h"
|
||||
#include "core/geometry_func.hpp"
|
||||
@@ -37,7 +37,7 @@
|
||||
#include "station_func.h"
|
||||
#include "zoom_func.h"
|
||||
#include "sortlist_type.h"
|
||||
#include "group_gui_list.h"
|
||||
#include "group_gui.h"
|
||||
#include "core/backup_type.hpp"
|
||||
|
||||
#include "widgets/company_widget.h"
|
||||
@@ -530,12 +530,12 @@ struct CompanyFinancesWindow : Window {
|
||||
|
||||
if (this->query_widget == WID_CF_INCREASE_LOAN) {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
Money amount = std::min<Money>(std::strtoull(str, nullptr, 10) / _currency->rate, _economy.max_loan - c->current_loan);
|
||||
Money amount = std::min<Money>(std::strtoull(str, nullptr, 10) / GetCurrency().rate, _economy.max_loan - c->current_loan);
|
||||
amount = LOAN_INTERVAL * CeilDivT<Money>(amount, LOAN_INTERVAL);
|
||||
DoCommandP(0, amount >> 32, (amount & 0xFFFFFFFC) | 2, CMD_INCREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_BORROW_ANY_MORE_MONEY));
|
||||
} else if (this->query_widget == WID_CF_REPAY_LOAN) {
|
||||
const Company *c = Company::Get((CompanyID)this->window_number);
|
||||
Money amount = std::min<Money>(std::strtoull(str, nullptr, 10) / _currency->rate, c->current_loan);
|
||||
Money amount = std::min<Money>(std::strtoull(str, nullptr, 10) / GetCurrency().rate, c->current_loan);
|
||||
amount = LOAN_INTERVAL * CeilDivT<Money>(amount, LOAN_INTERVAL);
|
||||
DoCommandP(0, amount >> 32, (amount & 0xFFFFFFFC) | 2, CMD_DECREASE_LOAN | CMD_MSG(STR_ERROR_CAN_T_REPAY_LOAN));
|
||||
}
|
||||
@@ -643,7 +643,6 @@ private:
|
||||
uint rows;
|
||||
uint line_height;
|
||||
GUIGroupList groups;
|
||||
std::vector<int> indents;
|
||||
Scrollbar *vscroll;
|
||||
|
||||
void ShowColourDropDownMenu(uint32_t widget)
|
||||
@@ -701,37 +700,16 @@ private:
|
||||
ShowDropDownList(this, std::move(list), sel, widget);
|
||||
}
|
||||
|
||||
void AddChildren(GUIGroupList &source, GroupID parent, int indent)
|
||||
{
|
||||
for (const Group *g : source) {
|
||||
if (g->parent != parent) continue;
|
||||
this->groups.push_back(g);
|
||||
this->indents.push_back(indent);
|
||||
AddChildren(source, g->index, indent + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void BuildGroupList(CompanyID owner)
|
||||
{
|
||||
if (!this->groups.NeedRebuild()) return;
|
||||
|
||||
this->groups.clear();
|
||||
this->indents.clear();
|
||||
|
||||
if (this->livery_class >= LC_GROUP_RAIL) {
|
||||
GUIGroupList list;
|
||||
VehicleType vtype = (VehicleType)(this->livery_class - LC_GROUP_RAIL);
|
||||
|
||||
for (const Group *g : Group::Iterate()) {
|
||||
if (g->owner == owner && g->vehicle_type == vtype) {
|
||||
list.push_back(g);
|
||||
}
|
||||
}
|
||||
|
||||
list.ForceResort();
|
||||
SortGUIGroupList(list);
|
||||
|
||||
AddChildren(list, INVALID_GROUP, 0);
|
||||
BuildGuiGroupList(this->groups, false, owner, vtype);
|
||||
}
|
||||
|
||||
this->groups.shrink_to_fit();
|
||||
@@ -795,7 +773,7 @@ public:
|
||||
|
||||
/* Position scrollbar to selected group */
|
||||
for (uint i = 0; i < this->rows; i++) {
|
||||
if (this->groups[i]->index == sel) {
|
||||
if (this->groups[i].group->index == sel) {
|
||||
this->vscroll->SetPosition(i - this->vscroll->GetCapacity() / 2);
|
||||
break;
|
||||
}
|
||||
@@ -965,11 +943,11 @@ public:
|
||||
}
|
||||
}
|
||||
} else {
|
||||
uint max = static_cast<uint>(std::min<size_t>(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size()));
|
||||
for (uint i = this->vscroll->GetPosition(); i < max; ++i) {
|
||||
const Group *g = this->groups[i];
|
||||
auto [first, last] = this->vscroll->GetVisibleRangeIterators(this->groups);
|
||||
for (auto it = first; it != last; ++it) {
|
||||
const Group *g = it->group;
|
||||
SetDParam(0, g->index);
|
||||
draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, this->indents[i] * WidgetDimensions::scaled.hsep_indent);
|
||||
draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, it->indent * WidgetDimensions::scaled.hsep_indent);
|
||||
}
|
||||
|
||||
if (this->vscroll->GetCount() == 0) {
|
||||
@@ -1012,7 +990,7 @@ public:
|
||||
this->BuildGroupList((CompanyID)this->window_number);
|
||||
|
||||
if (!this->groups.empty()) {
|
||||
this->sel = this->groups[0]->index;
|
||||
this->sel = this->groups[0].group->index;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1029,10 +1007,10 @@ public:
|
||||
break;
|
||||
|
||||
case WID_SCL_MATRIX: {
|
||||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_SCL_MATRIX);
|
||||
if (row >= this->rows) return;
|
||||
|
||||
if (this->livery_class < LC_GROUP_RAIL) {
|
||||
uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, widget);
|
||||
if (row >= this->rows) return;
|
||||
|
||||
LiveryScheme j = (LiveryScheme)row;
|
||||
|
||||
for (LiveryScheme scheme = LS_BEGIN; scheme <= j && scheme < LS_END; scheme++) {
|
||||
@@ -1046,7 +1024,10 @@ public:
|
||||
this->sel = 1 << j;
|
||||
}
|
||||
} else {
|
||||
this->sel = this->groups[row]->index;
|
||||
auto it = this->vscroll->GetScrolledItemFromWidget(this->groups, pt.y, this, widget);
|
||||
if (it == std::end(this->groups)) return;
|
||||
|
||||
this->sel = it->group->index;
|
||||
}
|
||||
this->SetDirty();
|
||||
break;
|
||||
@@ -1099,7 +1080,7 @@ public:
|
||||
|
||||
if (!Group::IsValidID(this->sel)) {
|
||||
this->sel = INVALID_GROUP;
|
||||
if (!this->groups.empty()) this->sel = this->groups[0]->index;
|
||||
if (!this->groups.empty()) this->sel = this->groups[0].group->index;
|
||||
}
|
||||
|
||||
this->SetDirty();
|
||||
@@ -2730,7 +2711,7 @@ struct CompanyWindow : Window
|
||||
default: NOT_REACHED();
|
||||
|
||||
case WID_C_GIVE_MONEY:
|
||||
DoCommandPEx(0, this->window_number, 0, (std::strtoull(str, nullptr, 10) / _currency->rate), CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), CcGiveMoney);
|
||||
DoCommandPEx(0, this->window_number, 0, (std::strtoull(str, nullptr, 10) / GetCurrency().rate), CMD_GIVE_MONEY | CMD_MSG(STR_ERROR_CAN_T_GIVE_MONEY), CcGiveMoney);
|
||||
break;
|
||||
|
||||
case WID_C_PRESIDENT_NAME:
|
||||
|
||||
Reference in New Issue
Block a user