Fixed compilatin, reverted several of my changes
This commit is contained in:
@@ -893,6 +893,7 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
|
||||
int sprite_width = sprite_left + sprite_right;
|
||||
|
||||
int sprite_x = rtl ? r - sprite_right - 1 : l + sprite_left + 1;
|
||||
int sprite_y_offset = sprite_y_offsets[type] + step_size / 2;
|
||||
|
||||
Dimension replace_icon = {0, 0};
|
||||
int count_width = 0;
|
||||
@@ -908,6 +909,10 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
|
||||
int count_left = l;
|
||||
int count_right = rtl ? text_left : r - WD_FRAMERECT_RIGHT - replace_icon.width - 8;
|
||||
|
||||
int normal_text_y_offset = (step_size - FONT_HEIGHT_NORMAL) / 2;
|
||||
int small_text_y_offset = step_size - FONT_HEIGHT_SMALL - WD_FRAMERECT_BOTTOM - 1;
|
||||
int replace_icon_y_offset = (step_size - replace_icon.height) / 2 - 1;
|
||||
|
||||
for (; min < max; min++, y += step_size) {
|
||||
const EngineID engine = (*eng_list)[min];
|
||||
/* Note: num_engines is only used in the autoreplace GUI, so it is correct to use _local_company here. */
|
||||
@@ -923,8 +928,8 @@ void DrawEngineList(VehicleType type, int l, int r, int y, const GUIEngineList *
|
||||
DrawVehicleEngine(l, r, sprite_x, y + sprite_y_offset, engine, (show_count && num_engines == 0) ? PALETTE_CRASH : GetEnginePalette(engine, _local_company), EIT_PURCHASE);
|
||||
if (show_count) {
|
||||
SetDParam(0, num_engines);
|
||||
DrawString(count_left, count_right, Center(y, step_size, FONT_HEIGHT_SMALL), STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
|
||||
if (EngineHasReplacementForCompany(Company::Get(_local_company), engine, selected_group)) DrawSprite(SPR_GROUP_REPLACE_ACTIVE, num_engines == 0 ? PALETTE_CRASH : PAL_NONE, replace_icon_left, Center(y, step_size, replace_icon.height));
|
||||
DrawString(count_left, count_right, y + small_text_y_offset, STR_TINY_BLACK_COMA, TC_FROMSTRING, SA_RIGHT | SA_FORCE);
|
||||
if (EngineHasReplacementForCompany(Company::Get(_local_company), engine, selected_group)) DrawSprite(SPR_GROUP_REPLACE_ACTIVE, num_engines == 0 ? PALETTE_CRASH : PAL_NONE, replace_icon_left, y + replace_icon_y_offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -641,7 +641,7 @@ public:
|
||||
|
||||
case WID_SL_LOAD_NETWORK_BUTTON: {
|
||||
char savePath[PATH_MAX];
|
||||
FiosMakeSavegameName(savePath, NETWORK_SAVE_FILENAME, sizeof(savePath));
|
||||
FiosMakeSavegameName(savePath, NETWORK_SAVE_FILENAME, lastof(savePath));
|
||||
#ifdef __ANDROID__
|
||||
if (!SDL_ANDROID_CloudLoad(savePath, NULL, "OpenTTD")) {
|
||||
break;
|
||||
|
||||
@@ -1206,7 +1206,7 @@ void ScreenSizeChanged()
|
||||
/* screen size changed and the old bitmap is invalid now, so we don't want to undraw it */
|
||||
_cursor.visible = false;
|
||||
|
||||
NWidgetScrollbar::ResetAllWidgetMinSizes();
|
||||
ResetAllWidgetMinSizes();
|
||||
}
|
||||
|
||||
void UndrawMouseCursor()
|
||||
|
||||
@@ -607,8 +607,7 @@ public:
|
||||
case ContentInfo::DOES_NOT_EXIST: sprite = SPR_BLOT; pal = PALETTE_TO_RED; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
DrawSprite(sprite, pal, Center(nwi_checkbox->pos_x + (pal == PAL_NONE ? 2 : 3), nwi_checkbox->current_x, sprite_dim.width), Center(y, this->resize.step_height, sprite_dim.height + (pal == PAL_NONE ? 0 : -2)));
|
||||
DrawSprite(sprite, pal, nwi_checkbox->pos_x + (pal == PAL_NONE ? 2 : 3), y + sprite_y_offset + (pal == PAL_NONE ? 1 : 0));
|
||||
|
||||
StringID str = STR_CONTENT_TYPE_BASE_GRAPHICS + ci->type - CONTENT_TYPE_BASE_GRAPHICS;
|
||||
DrawString(nwi_type->pos_x, nwi_type->pos_x + nwi_type->current_x - 1, y + text_y_offset, str, TC_BLACK, SA_HOR_CENTER);
|
||||
|
||||
@@ -1176,7 +1176,7 @@ void SwitchToMode(SwitchMode new_mode)
|
||||
lastPart++;
|
||||
}
|
||||
MakeScreenshot(SC_VIEWPORT, NETWORK_SAVE_SCREENSHOT_FILE);
|
||||
FioFindFullPath(screenshotFile, sizeof(screenshotFile), SCREENSHOT_DIR, NETWORK_SAVE_SCREENSHOT_FILE_PNG);
|
||||
FioFindFullPath(screenshotFile, lastof(screenshotFile), SCREENSHOT_DIR, NETWORK_SAVE_SCREENSHOT_FILE_PNG);
|
||||
uint64_t playedTime = abs(_date - DAYS_TILL(_settings_newgame.game_creation.starting_year)) * 1000;
|
||||
int ret = SDL_ANDROID_CloudSave(_file_to_saveload.name, lastPart, "OpenTTD", lastPart, screenshotFile, playedTime);
|
||||
if (_settings_client.gui.save_to_network == 2) {
|
||||
|
||||
@@ -807,17 +807,13 @@ static const NWidgetPart _nested_station_view_widgets[] = {
|
||||
* @param y y coordinate
|
||||
* @param width the width of the view
|
||||
*/
|
||||
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int top, int bottom)
|
||||
static void DrawCargoIcons(CargoID i, uint waiting, int left, int right, int top, int y)
|
||||
{
|
||||
int width = ScaleGUITrad(10);
|
||||
uint num = min((waiting + (width / 2)) / width, (right - left) / width); // maximum is width / 10 icons so it won't overflow
|
||||
if (num == 0) return;
|
||||
|
||||
SpriteID sprite = CargoSpec::Get(i)->GetCargoIcon();
|
||||
Dimension d = GetSpriteSize(sprite);
|
||||
|
||||
uint num = min((waiting + 5) / d.width, (right - left) / d.width); // maximum is width / 10 icons so it won't overflow
|
||||
if (num == 0) return;
|
||||
|
||||
int x = _current_text_dir == TD_RTL ? left : right - num * width;
|
||||
do {
|
||||
|
||||
@@ -1418,9 +1418,11 @@ public:
|
||||
}
|
||||
_toolbar_width = nbuttons * this->smallest_x;
|
||||
if (type == NWID_HORIZONTAL) {
|
||||
w->window_desc->default_width = nbuttons * this->smallest_x;
|
||||
//w->window_desc->default_width_trad = nbuttons * this->smallest_x;
|
||||
w->window_desc->pref_width = nbuttons * this->smallest_x;
|
||||
} else {
|
||||
w->window_desc->default_height = nbuttons * this->smallest_y;
|
||||
//w->window_desc->default_height_trad = nbuttons * this->smallest_y;
|
||||
w->window_desc->pref_height = nbuttons * this->smallest_y;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2067,9 +2067,6 @@ void NWidgetScrollbar::Draw(const Window *w)
|
||||
horizontal_dimension.height = GetMinSizing(NWST_STEP, horizontal_dimension.height);
|
||||
}
|
||||
return horizontal_dimension;
|
||||
SETTING_BUTTON_HEIGHT = max<int>(GetMinSizing(NWST_STEP) - 10, 10);
|
||||
SETTING_BUTTON_WIDTH = 2 * SETTING_BUTTON_HEIGHT;
|
||||
|
||||
}
|
||||
|
||||
Dimension NWidgetScrollbar::vertical_dimension = {0, 0};
|
||||
@@ -2135,7 +2132,6 @@ NWidgetLeaf::NWidgetLeaf(WidgetType tp, Colours colour, int index, uint32 data,
|
||||
case NWID_BUTTON_DROPDOWN:
|
||||
case WWT_DROPDOWN:
|
||||
case WWT_ARROWBTN:
|
||||
case WWT_PUSHARROWBTN:
|
||||
this->sizing_type = NWST_STEP;
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -773,7 +773,7 @@ public:
|
||||
static void InvalidateDimensionCache();
|
||||
static Dimension GetVerticalDimension();
|
||||
static Dimension GetHorizontalDimension();
|
||||
static void ResetAllWidgetMinSizes(); ///< Called when screen size or font size or button size changes
|
||||
friend void ResetAllWidgetMinSizes(); ///< Called when screen size or font size or button size changes
|
||||
|
||||
private:
|
||||
static Dimension vertical_dimension; ///< Cached size of vertical scrollbar button.
|
||||
|
||||
@@ -362,14 +362,6 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
/* Longest item in the list, if auto_width is enabled */
|
||||
uint max_item_width = 0;
|
||||
|
||||
if (auto_width) {
|
||||
/* Find the longest item in the list */
|
||||
for (const DropDownListItem * const *it = list->Begin(); it != list->End(); ++it) {
|
||||
const DropDownListItem *item = *it;
|
||||
max_item_width = max(max_item_width, item->Width() + 5);
|
||||
}
|
||||
}
|
||||
|
||||
/* Total length of list */
|
||||
int height = 0;
|
||||
|
||||
@@ -383,14 +375,11 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
int screen_bottom = GetMainViewBottom();
|
||||
bool scroll = false;
|
||||
|
||||
enum { DISPLAY_BORDER = 20, TOP_BORDER = 4 };
|
||||
|
||||
/* Check if the dropdown will fully fit below the widget. */
|
||||
if (top + height + DISPLAY_BORDER >= screen_bottom) {
|
||||
/* If not, check if it will fit above the widget. */
|
||||
int screen_top = GetMainViewTop();
|
||||
if (w->top + wi_rect.top - TOP_BORDER > screen_top + height) {
|
||||
top = w->top + wi_rect.top - height - TOP_BORDER;
|
||||
/* Check if the dropdown will fully fit below the widget */
|
||||
if (top + height + 4 >= screen_bottom) {
|
||||
/* If not, check if it will fit above the widget */
|
||||
if (w->top + wi_rect.top - height > GetMainViewTop()) {
|
||||
top = w->top + wi_rect.top - height - 4;
|
||||
} else {
|
||||
/* ... and lastly if it won't, enable the scroll bar and fit the
|
||||
* list in below the widget */
|
||||
@@ -398,30 +387,9 @@ void ShowDropDownListAt(Window *w, const DropDownList *list, int selected, int b
|
||||
int rows = (screen_bottom - 4 - top) / avg_height;
|
||||
height = rows * avg_height;
|
||||
scroll = true;
|
||||
|
||||
/* ... and choose whether to put the list above or below the widget. */
|
||||
bool put_above = false;
|
||||
int available_height = screen_bottom - w->top - wi_rect.bottom;
|
||||
if (w->top + wi_rect.top - screen_top > available_height) {
|
||||
// Put it above.
|
||||
available_height = w->top + wi_rect.top - screen_top - DISPLAY_BORDER - TOP_BORDER;
|
||||
put_above = true;
|
||||
}
|
||||
|
||||
/* Check at least there is space for one item. */
|
||||
assert(available_height >= avg_height);
|
||||
|
||||
/* And lastly, fit the list,... */
|
||||
int rows = available_height / avg_height;
|
||||
height = rows * avg_height;
|
||||
|
||||
/* ... add space for the scrollbar,... */
|
||||
/* Add space for the scroll bar if we automatically determined
|
||||
* the width of the list. */
|
||||
max_item_width += NWidgetScrollbar::GetVerticalDimension().width;
|
||||
|
||||
/* ... and set the top position if needed. */
|
||||
if (put_above) {
|
||||
top = w->top + wi_rect.top - height - TOP_BORDER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1874,7 +1874,7 @@ Window *FindWindowFromPt(int x, int y)
|
||||
* @todo Check if it can be moved to another file, so we do not need to include error, string and fontcache headers.
|
||||
* @todo Fix magic numbers 16/18/20/30/32
|
||||
*/
|
||||
void NWidgetScrollbar::ResetAllWidgetMinSizes()
|
||||
void ResetAllWidgetMinSizes()
|
||||
{
|
||||
NWidgetScrollbar::vertical_dimension = {0, 0};
|
||||
NWidgetScrollbar::horizontal_dimension = {0, 0};
|
||||
@@ -3586,7 +3586,7 @@ void RelocateAllWindows(int neww, int newh)
|
||||
break;
|
||||
|
||||
case WC_MAIN_TOOLBAR_RIGHT:
|
||||
ResizeWindow(w, min(neww, w->window_desc->default_width) - w->width, 0, false);
|
||||
ResizeWindow(w, min(neww, _toolbar_width) - w->width, 0, false);
|
||||
|
||||
top = w->top;
|
||||
left = neww - w->width;
|
||||
|
||||
@@ -29,6 +29,7 @@ int PositionNetworkChatWindow(Window *w);
|
||||
int GetMainViewTop();
|
||||
int GetMainViewBottom();
|
||||
|
||||
void ResetAllWidgetMinSizes();
|
||||
void InitWindowSystem();
|
||||
void UnInitWindowSystem();
|
||||
void ResetWindowSystem();
|
||||
|
||||
Reference in New Issue
Block a user