Refactor extra(land) tooltips and split into 3 settings in config
This commit is contained in:
@@ -1229,6 +1229,8 @@ citymania/cm_game.hpp
|
||||
citymania/cm_game.cpp
|
||||
citymania/cm_main.hpp
|
||||
citymania/cm_main.cpp
|
||||
citymania/cm_tooltips.hpp
|
||||
citymania/cm_tooltips.cpp
|
||||
citymania/cm_type.hpp
|
||||
citymania/extensions/cmext_town.hpp
|
||||
citymania/extensions/cmext_company.hpp
|
||||
|
||||
262
src/citymania/cm_tooltips.cpp
Normal file
262
src/citymania/cm_tooltips.cpp
Normal file
@@ -0,0 +1,262 @@
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "cm_tooltips.hpp"
|
||||
|
||||
#include "../house.h"
|
||||
#include "../industry.h"
|
||||
#include "../station_base.h"
|
||||
#include "../station_map.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../tile_type.h"
|
||||
#include "../town_map.h"
|
||||
#include "../window_func.h"
|
||||
#include "../window_gui.h"
|
||||
#include "../zoom_func.h"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
namespace citymania {
|
||||
|
||||
static const NWidgetPart _nested_land_tooltips_widgets[] = {
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, 0), SetMinimalSize(64, 32), EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _land_tooltips_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
CM_WC_LAND_TOOLTIPS, WC_NONE,
|
||||
0,
|
||||
_nested_land_tooltips_widgets, lengthof(_nested_land_tooltips_widgets)
|
||||
);
|
||||
|
||||
struct LandTooltipsWindow : public Window
|
||||
{
|
||||
TileType tiletype;
|
||||
uint16 objIndex;
|
||||
|
||||
LandTooltipsWindow(Window *parent, uint param) : Window(&_land_tooltips_desc)
|
||||
{
|
||||
this->parent = parent;
|
||||
this->tiletype = (TileType)(param & 0xFFFF);
|
||||
this->objIndex = (uint16)((param >> 16) & 0xFFFF);
|
||||
this->InitNested();
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
}
|
||||
|
||||
virtual ~LandTooltipsWindow() {}
|
||||
|
||||
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
|
||||
{
|
||||
int scr_top = GetMainViewTop() + 2;
|
||||
int scr_bot = GetMainViewBottom() - 2;
|
||||
Point pt;
|
||||
pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
|
||||
if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
|
||||
pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
|
||||
return pt;
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
{
|
||||
uint icon_size = ScaleGUITrad(10);
|
||||
uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
|
||||
uint icons_width = icon_size * 3 + 20;
|
||||
size->width = 200;
|
||||
size->height = 6 + FONT_HEIGHT_NORMAL;
|
||||
switch(this->tiletype) {
|
||||
case MP_HOUSE: {
|
||||
const HouseSpec *hs = HouseSpec::Get((HouseID)this->objIndex);
|
||||
if(hs == NULL) break;
|
||||
SetDParam(0, hs->building_name);
|
||||
size->width = GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_HOUSE_NAME).width;
|
||||
size->height += line_height;
|
||||
SetDParam(0, hs->population);
|
||||
size->width = max(size->width, GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_HOUSE_POPULATION).width);
|
||||
break;
|
||||
}
|
||||
case MP_INDUSTRY: {
|
||||
const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
|
||||
if(ind == NULL) break;
|
||||
|
||||
SetDParam(0, ind->index);
|
||||
size->width = max(GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_INDUSTRY_NAME).width, size->width);
|
||||
|
||||
for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
if (ind->produced_cargo[i] == CT_INVALID) continue;
|
||||
const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
|
||||
if(cs == NULL) continue;
|
||||
size->height += line_height;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cs->Index());
|
||||
SetDParam(2, ind->last_month_production[i]);
|
||||
SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
|
||||
size->width = max(GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_INDUSTRY_CARGO).width + icons_width, size->width);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
const Station *st = Station::GetIfValid((StationID)this->objIndex);
|
||||
if(st == NULL) break;
|
||||
|
||||
SetDParam(0, st->index);
|
||||
size->width = max(GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_STATION_NAME).width, size->width);
|
||||
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
if(cs == NULL) continue;
|
||||
int cargoid = cs->Index();
|
||||
if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
|
||||
size->height += line_height;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cargoid);
|
||||
SetDParam(2, st->goods[cargoid].cargo.TotalCount());
|
||||
SetDParam(3, ToPercent8(st->goods[cargoid].rating));
|
||||
size->width = max(GetStringBoundingBox(STR_CM_LAND_TOOLTIPS_STATION_CARGO).width + icons_width, size->width);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
size->width += 8 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
uint icon_size = ScaleGUITrad(10);
|
||||
uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
|
||||
uint icons_width = icon_size * 3 + 10;
|
||||
uint text_ofs = (line_height - FONT_HEIGHT_NORMAL) >> 1;
|
||||
uint icon_ofs = (line_height - icon_size) >> 1;
|
||||
|
||||
GfxDrawLine(r.left, r.top, r.right, r.top, PC_BLACK);
|
||||
GfxDrawLine(r.left, r.bottom, r.right, r.bottom, PC_BLACK);
|
||||
GfxDrawLine(r.left, r.top, r.left, r.bottom, PC_BLACK);
|
||||
GfxDrawLine(r.right, r.top, r.right, r.bottom, PC_BLACK);
|
||||
|
||||
int y = r.top + WD_FRAMERECT_TOP + 4;
|
||||
int left = r.left + WD_FRAMERECT_LEFT + 4;
|
||||
int right = r.right - WD_FRAMERECT_RIGHT - 4;
|
||||
|
||||
switch(this->tiletype) {
|
||||
case MP_HOUSE: {
|
||||
const HouseSpec *hs = HouseSpec::Get((HouseID)this->objIndex);
|
||||
if(hs == NULL) break;
|
||||
|
||||
SetDParam(0, hs->building_name);
|
||||
DrawString(left, right, y, STR_CM_LAND_TOOLTIPS_HOUSE_NAME, TC_BLACK, SA_CENTER);
|
||||
y += FONT_HEIGHT_NORMAL + 2;
|
||||
SetDParam(0, hs->population);
|
||||
DrawString(left, right, y, STR_CM_LAND_TOOLTIPS_HOUSE_POPULATION, TC_BLACK, SA_CENTER);
|
||||
break;
|
||||
}
|
||||
case MP_INDUSTRY: {
|
||||
const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
|
||||
if(ind == NULL) break;
|
||||
|
||||
SetDParam(0, ind->index);
|
||||
DrawString(left, right, y, STR_CM_LAND_TOOLTIPS_INDUSTRY_NAME, TC_BLACK, SA_CENTER);
|
||||
y += FONT_HEIGHT_NORMAL + 2;
|
||||
|
||||
for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
if (ind->produced_cargo[i] == CT_INVALID) continue;
|
||||
const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
|
||||
if(cs == NULL) continue;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cs->Index());
|
||||
SetDParam(2, ind->last_month_production[i]);
|
||||
SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
|
||||
|
||||
this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
|
||||
DrawString(left + icons_width, right, y + text_ofs, STR_CM_LAND_TOOLTIPS_INDUSTRY_CARGO);
|
||||
y += line_height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
const Station *st = Station::GetIfValid((StationID)this->objIndex);
|
||||
if(st == NULL) break;
|
||||
|
||||
SetDParam(0, st->index);
|
||||
DrawString(left, right, y, STR_CM_LAND_TOOLTIPS_STATION_NAME, TC_BLACK, SA_CENTER);
|
||||
y += FONT_HEIGHT_NORMAL + 2;
|
||||
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
if(cs == NULL) continue;
|
||||
int cargoid = cs->Index();
|
||||
if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cargoid);
|
||||
SetDParam(2, st->goods[cargoid].cargo.TotalCount());
|
||||
SetDParam(3, ToPercent8(st->goods[cargoid].rating));
|
||||
|
||||
this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
|
||||
DrawString(left + icons_width, right, y + text_ofs, STR_CM_LAND_TOOLTIPS_STATION_CARGO);
|
||||
y += line_height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// virtual void OnMouseLoop()
|
||||
// {
|
||||
// if (!_cursor.in_window || !_mouse_hovering) {
|
||||
// delete this;
|
||||
// }
|
||||
// }
|
||||
|
||||
void DrawSpriteIcons(SpriteID sprite, int left, int top) const
|
||||
{
|
||||
uint step = ScaleGUITrad(10);
|
||||
for(int i = 0; i < 3; i++) {
|
||||
DrawSprite(sprite, PAL_NONE, left + i * step, top);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void ShowLandTooltips(TileIndex tile, Window *parent) {
|
||||
static TileIndex last_tooltip_tile = INVALID_TILE;
|
||||
if (tile == last_tooltip_tile) return;
|
||||
last_tooltip_tile = tile;
|
||||
|
||||
uint param = 0;
|
||||
switch (GetTileType(tile)) {
|
||||
case MP_HOUSE: {
|
||||
if (_settings_client.gui.cm_land_tooltips_for_houses) {
|
||||
const HouseID house = GetHouseType(tile);
|
||||
param = ((house & 0xFFFF) << 16) | MP_HOUSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_INDUSTRY: {
|
||||
if (_settings_client.gui.cm_land_tooltips_for_industries) {
|
||||
const Industry *ind = Industry::GetByTile(tile);
|
||||
// if(ind->produced_cargo[0] == CT_INVALID && ind->produced_cargo[1] == CT_INVALID) return;
|
||||
param = ((ind->index & 0xFFFF) << 16) | MP_INDUSTRY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
if (_settings_client.gui.cm_land_tooltips_for_stations) {
|
||||
if (IsRailWaypoint(tile) || HasTileWaterGround(tile)) break;
|
||||
const Station *st = Station::GetByTile(tile);
|
||||
param |= ((st->index & 0xFFFF) << 16) | MP_STATION;
|
||||
break;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
DeleteWindowById(CM_WC_LAND_TOOLTIPS, 0);
|
||||
|
||||
if (param == 0) return;
|
||||
new LandTooltipsWindow(parent, param);
|
||||
}
|
||||
|
||||
} // namespace citymania
|
||||
15
src/citymania/cm_tooltips.hpp
Normal file
15
src/citymania/cm_tooltips.hpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef CM_TOOLTIPS_HPP
|
||||
#define CM_TOOLTIPS_HPP
|
||||
|
||||
#include "../tile_type.h"
|
||||
#include "../window_type.h"
|
||||
|
||||
class LandInfoWindow;
|
||||
|
||||
namespace citymania {
|
||||
|
||||
void ShowLandTooltips(TileIndex tile, Window *parent);
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
#endif
|
||||
@@ -11,7 +11,7 @@ public:
|
||||
Money cargo_income[NUM_CARGO]; ///< Cargo income from each cargo type
|
||||
};
|
||||
|
||||
} // namespace citymania
|
||||
} // namespace ext
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
uint16 houses_demolished_last_month = 0; ///< number of houses demolished last month
|
||||
};
|
||||
|
||||
} // namespace citymania
|
||||
} // namespace ext
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
|
||||
@@ -5437,16 +5437,6 @@ STR_TOWN_CB_CARGO_FROM_NOT :{SILVER}{COMMA}
|
||||
#polyrail double click option
|
||||
STR_CONFIG_SETTING_POLYRAIL_DOUBLECLICK_TOOLTIPS :Enable finishing polyrail with mouse double click{STRING2}
|
||||
|
||||
#tooltips extra
|
||||
STR_CONFIG_SETTING_ENABLE_EXTRA_TOOLTIPS :Enable extra tooltips: {STRING2}
|
||||
STR_TTE_HOUSE_NAME :{LTBLUE}{STRING}
|
||||
STR_TTE_HOUSE :{BLACK}Population: {NUM}
|
||||
STR_TTE_INDUSTRY_NAME :{LTBLUE}{INDUSTRY}
|
||||
STR_TTE_INDUSTRY :{WHITE}{STRING} {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
|
||||
STR_TTE_STATION_NAME :{LTBLUE}{STATION}
|
||||
STR_TTE_STATION :{WHITE}{STRING} {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
|
||||
STR_LAND_AREA_INFORMATION_POP :{BLACK}Population: {LTBLUE}{NUM}
|
||||
|
||||
# Industry funding forbidden tiles
|
||||
STR_FUND_INDUSTRY_FORBIDDEN_TILES_TITLE :{BLACK}Forbidden areas highlight
|
||||
STR_FUND_INDUSTRY_FORBIDDEN_TILES_OFF :{BLACK}Off
|
||||
@@ -5519,3 +5509,20 @@ STR_CM_PURCHASE_ENGINE_ID :{BLACK}Engine ID: {GOLD}{NUM}
|
||||
STR_CM_SMALLMAP_TOOLTIP_SHOW_IMBA_ON_MAP :{BLACK}Show industries on map combined with land contours and vegetation
|
||||
STR_CM_CONFIG_SETTING_PAUSE_AFTER_LOAD :Pause the game after loading: {STRING2}
|
||||
STR_CM_CONFIG_SETTING_PAUSE_AFTER_LOAD_HELPTEXT :Control whether the game should be paused after load (if it's not already paused). Useful for desync debugging.
|
||||
|
||||
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_HOUSES :Show tooltips when hovering over houses: {STRING2}
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_INDUSTRIES :Show tooltips when hovering over industries: {STRING2}
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_STATIONS :Show tooltips when hovering over stations: {STRING2}
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_HOUSES_HELPTEXT :Show tooltips when hovering over houses in the viewport. {GOLD}(CityMania addon)
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_INDUSTRIES_HELPTEXT :Show tooltips when hovering over industries in the viewport. {GOLD}(CityMania addon)
|
||||
STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_STATIONS_HELPTEXT :Show tooltips when hovering over stations in the viewport. {GOLD}(CityMania addon)
|
||||
STR_CM_LAND_TOOLTIPS_HOUSE_NAME :{LTBLUE}{STRING}
|
||||
STR_CM_LAND_TOOLTIPS_HOUSE_POPULATION :{BLACK}Population: {NUM}
|
||||
STR_CM_LAND_TOOLTIPS_INDUSTRY_NAME :{LTBLUE}{INDUSTRY}
|
||||
STR_CM_LAND_TOOLTIPS_INDUSTRY_CARGO :{WHITE}{STRING} {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
|
||||
STR_CM_LAND_TOOLTIPS_STATION_NAME :{LTBLUE}{STATION}
|
||||
STR_CM_LAND_TOOLTIPS_STATION_CARGO :{WHITE}{STRING} {BLACK}{CARGO_SHORT} {YELLOW}{NUM} %
|
||||
|
||||
STR_LAND_AREA_INFORMATION_POP :{BLACK}Population: {LTBLUE}{NUM}
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ struct MainWindow : Window
|
||||
|
||||
virtual void OnMouseOver(Point pt, int widget)
|
||||
{
|
||||
if (_game_mode != GM_MENU && _settings_client.gui.enable_extra_tooltips && pt.x != -1) GuiPrepareTooltipsExtra(this);
|
||||
if (_game_mode != GM_MENU && pt.x != -1) GuiPrepareTooltipsExtra(this);
|
||||
}
|
||||
|
||||
static HotkeyList hotkeys;
|
||||
|
||||
241
src/misc_gui.cpp
241
src/misc_gui.cpp
@@ -38,12 +38,12 @@
|
||||
#include "viewport_func.h"
|
||||
#include "industry.h"
|
||||
|
||||
#include "citymania/cm_tooltips.hpp"
|
||||
|
||||
#include "safeguards.h"
|
||||
|
||||
extern const Station *_viewport_highlight_station; // CM
|
||||
|
||||
void GuiShowTooltipsExtra(Window *parent, uint param, TooltipCloseCondition close_tooltip);
|
||||
|
||||
/** Method to open the OSK. */
|
||||
enum OskActivation {
|
||||
OSKA_DISABLED, ///< The OSK shall not be activated at all.
|
||||
@@ -1340,237 +1340,10 @@ void GuiPrepareTooltipsExtra(Window *parent){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_settings_client.gui.enable_extra_tooltips)
|
||||
return;
|
||||
|
||||
if (tile >= MapSize()) return;
|
||||
uint param = 0;
|
||||
switch (GetTileType(tile)) {
|
||||
/*case MP_HOUSE: {
|
||||
const HouseID house = GetHouseType(tile);
|
||||
param = ((house & 0xFFFF) << 16) | MP_HOUSE;
|
||||
break;
|
||||
}*/
|
||||
case MP_INDUSTRY: {
|
||||
const Industry *ind = Industry::GetByTile(tile);
|
||||
if(ind->produced_cargo[0] == CT_INVALID && ind->produced_cargo[1] == CT_INVALID) return;
|
||||
param = ((ind->index & 0xFFFF) << 16) | MP_INDUSTRY;
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
if (IsRailWaypoint(tile) || HasTileWaterGround(tile)) break;
|
||||
const Station *st = Station::GetByTile(tile);
|
||||
param |= ((st->index & 0xFFFF) << 16) | MP_STATION;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
if(param != 0) GuiShowTooltipsExtra(parent, param, TCC_HOVER);
|
||||
citymania::ShowLandTooltips(tile, parent);
|
||||
}
|
||||
|
||||
static const NWidgetPart _nested_tooltips_extra_widgets[] = {
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32), EndContainer(),
|
||||
};
|
||||
|
||||
static WindowDesc _tool_tips_extra_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WC_TOOLTIPS_EXTRA, WC_NONE,
|
||||
0,
|
||||
_nested_tooltips_extra_widgets, lengthof(_nested_tooltips_extra_widgets)
|
||||
);
|
||||
|
||||
struct TooltipsExtraWindow : public Window
|
||||
{
|
||||
TileType tiletype;
|
||||
uint16 objIndex;
|
||||
TooltipCloseCondition close_cond;
|
||||
|
||||
TooltipsExtraWindow(Window *parent, uint param, TooltipCloseCondition close_tooltip) : Window(&_tool_tips_extra_desc)
|
||||
{
|
||||
this->parent = parent;
|
||||
this->tiletype = (TileType)(param & 0xFFFF);
|
||||
this->objIndex = (uint16)((param >> 16) & 0xFFFF);
|
||||
this->close_cond = close_tooltip;
|
||||
this->InitNested();
|
||||
CLRBITS(this->flags, WF_WHITE_BORDER);
|
||||
}
|
||||
|
||||
virtual Point OnInitialPosition(int16 sm_width, int16 sm_height, int window_number)
|
||||
{
|
||||
int scr_top = GetMainViewTop() + 2;
|
||||
int scr_bot = GetMainViewBottom() - 2;
|
||||
Point pt;
|
||||
pt.y = Clamp(_cursor.pos.y + _cursor.total_size.y + _cursor.total_offs.y + 5, scr_top, scr_bot);
|
||||
if (pt.y + sm_height > scr_bot) pt.y = min(_cursor.pos.y + _cursor.total_offs.y - 5, scr_bot) - sm_height;
|
||||
pt.x = sm_width >= _screen.width ? 0 : Clamp(_cursor.pos.x - (sm_width >> 1), 0, _screen.width - sm_width);
|
||||
return pt;
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
{
|
||||
uint icon_size = ScaleGUITrad(10);
|
||||
uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
|
||||
uint icons_width = icon_size * 3 + 20;
|
||||
size->width = 200;
|
||||
size->height = FONT_HEIGHT_NORMAL + 6;
|
||||
switch(this->tiletype) {
|
||||
/*case MP_HOUSE: {
|
||||
size->height += LINE_HEIGHT;
|
||||
SetDParam(0, 1000);
|
||||
size->width = GetStringBoundingBox(STR_TTE_HOUSE).width;
|
||||
break;
|
||||
}*/
|
||||
case MP_INDUSTRY: {
|
||||
const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
|
||||
if(ind == NULL) break;
|
||||
|
||||
for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
if (ind->produced_cargo[i] == CT_INVALID) continue;
|
||||
const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
|
||||
if(cs == NULL) continue;
|
||||
size->height += line_height;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cs->Index());
|
||||
SetDParam(2, ind->last_month_production[i]);
|
||||
SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
|
||||
size->width = max(GetStringBoundingBox(STR_TTE_INDUSTRY).width + icons_width, size->width);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
const Station *st = Station::GetIfValid((StationID)this->objIndex);
|
||||
if(st == NULL) break;
|
||||
|
||||
SetDParam(0, st->index);
|
||||
size->width = max(GetStringBoundingBox(STR_TTE_STATION_NAME).width, size->width);
|
||||
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
if(cs == NULL) continue;
|
||||
int cargoid = cs->Index();
|
||||
if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
|
||||
size->height += line_height;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cargoid);
|
||||
SetDParam(2, st->goods[cargoid].cargo.TotalCount());
|
||||
SetDParam(3, ToPercent8(st->goods[cargoid].rating));
|
||||
size->width = max(GetStringBoundingBox(STR_TTE_STATION).width + icons_width, size->width);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
size->width += 2 + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
size->height += 2 + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
}
|
||||
|
||||
virtual void DrawWidget(const Rect &r, int widget) const
|
||||
{
|
||||
uint icon_size = ScaleGUITrad(10);
|
||||
uint line_height = max((uint)FONT_HEIGHT_NORMAL, icon_size) + 2;
|
||||
uint icons_width = icon_size * 3 + 10;
|
||||
uint text_ofs = (line_height - FONT_HEIGHT_NORMAL) >> 1;
|
||||
uint icon_ofs = (line_height - icon_size) >> 1;
|
||||
|
||||
GfxDrawLine(r.left, r.top, r.right, r.top, PC_BLACK);
|
||||
GfxDrawLine(r.left, r.bottom, r.right, r.bottom, PC_BLACK);
|
||||
GfxDrawLine(r.left, r.top, r.left, r.bottom, PC_BLACK);
|
||||
GfxDrawLine(r.right, r.top, r.right, r.bottom, PC_BLACK);
|
||||
|
||||
int y = r.top + WD_FRAMERECT_TOP + 4;
|
||||
int left = r.left + WD_FRAMERECT_LEFT + 4;
|
||||
|
||||
switch(this->tiletype) {
|
||||
/*case MP_HOUSE: {
|
||||
const HouseID house = (HouseID)this->objIndex;
|
||||
const HouseSpec *hs = HouseSpec::Get(house);
|
||||
if(hs == NULL) break;
|
||||
|
||||
SetDParam(0, hs->building_name);
|
||||
DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_HOUSE_NAME, TC_BLACK, SA_CENTER);
|
||||
y += LINE_HEIGHT;
|
||||
SetDParam(0, hs->population);
|
||||
DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_HOUSE);
|
||||
break;
|
||||
}*/
|
||||
case MP_INDUSTRY: {
|
||||
const Industry *ind = Industry::GetIfValid((IndustryID)this->objIndex);
|
||||
if(ind == NULL) break;
|
||||
|
||||
SetDParam(0, ind->index);
|
||||
DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_INDUSTRY_NAME, TC_BLACK, SA_CENTER);
|
||||
y += FONT_HEIGHT_NORMAL + 2;
|
||||
|
||||
for (CargoID i = 0; i < lengthof(ind->produced_cargo); i++) {
|
||||
if (ind->produced_cargo[i] == CT_INVALID) continue;
|
||||
const CargoSpec *cs = CargoSpec::Get(ind->produced_cargo[i]);
|
||||
if(cs == NULL) continue;
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cs->Index());
|
||||
SetDParam(2, ind->last_month_production[i]);
|
||||
SetDParam(3, ToPercent8(ind->last_month_pct_transported[i]));
|
||||
|
||||
this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
|
||||
DrawString(left + icons_width, r.right - WD_FRAMERECT_RIGHT, y + text_ofs, STR_TTE_INDUSTRY);
|
||||
y += line_height;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MP_STATION: {
|
||||
const Station *st = Station::GetIfValid((StationID)this->objIndex);
|
||||
if(st == NULL) break;
|
||||
|
||||
SetDParam(0, st->index);
|
||||
DrawString(left, r.right - WD_FRAMERECT_RIGHT, y, STR_TTE_STATION_NAME, TC_BLACK, SA_CENTER);
|
||||
y += FONT_HEIGHT_NORMAL + 2;
|
||||
|
||||
for (int i = 0; i < _sorted_standard_cargo_specs_size; i++) {
|
||||
const CargoSpec *cs = _sorted_cargo_specs[i];
|
||||
if(cs == NULL) continue;
|
||||
int cargoid = cs->Index();
|
||||
if (HasBit(st->goods[cargoid].status, GoodsEntry::GES_RATING)) {
|
||||
SetDParam(0, cs->name);
|
||||
SetDParam(1, cargoid);
|
||||
SetDParam(2, st->goods[cargoid].cargo.TotalCount());
|
||||
SetDParam(3, ToPercent8(st->goods[cargoid].rating));
|
||||
|
||||
this->DrawSpriteIcons(cs->GetCargoIcon(), left, y + icon_ofs);
|
||||
DrawString(left + icons_width, r.right - WD_FRAMERECT_RIGHT, y + text_ofs, STR_TTE_STATION);
|
||||
y += line_height;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
virtual void OnMouseLoop()
|
||||
{
|
||||
if (!_cursor.in_window) {
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
|
||||
switch (this->close_cond) {
|
||||
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
|
||||
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
|
||||
case TCC_NONE: break;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawSpriteIcons(SpriteID sprite, int left, int top) const
|
||||
{
|
||||
uint step = ScaleGUITrad(10);
|
||||
for(int i = 0; i < 3; i++) {
|
||||
DrawSprite(sprite, PAL_NONE, left + i * step, top);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
static const NWidgetPart _nested_station_rating_tooltip_widgets[] = {
|
||||
NWidget(WWT_PANEL, COLOUR_GREY, WID_TT_BACKGROUND), SetMinimalSize(64, 32), EndContainer(),
|
||||
@@ -1580,7 +1353,7 @@ static WindowDesc _station_rating_tooltip_desc(
|
||||
WDP_MANUAL, NULL, 0, 0,
|
||||
WC_STATION_RATING_TOOLTIP, WC_NONE,
|
||||
0,
|
||||
_nested_tooltips_extra_widgets, lengthof(_nested_station_rating_tooltip_widgets)
|
||||
_nested_station_rating_tooltip_widgets, lengthof(_nested_station_rating_tooltip_widgets)
|
||||
);
|
||||
|
||||
static const int STATION_RATING_AGE[] = {0, 10, 20, 33};
|
||||
@@ -1807,12 +1580,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void GuiShowTooltipsExtra(Window *parent, uint param, TooltipCloseCondition close_tooltip)
|
||||
{
|
||||
DeleteWindowById(WC_TOOLTIPS_EXTRA, 0);
|
||||
new TooltipsExtraWindow(parent, param, close_tooltip);
|
||||
}
|
||||
|
||||
void GuiShowStationRatingTooltip(Window *parent, const Station *st, const CargoSpec *cs) {
|
||||
DeleteWindowById(WC_STATION_RATING_TOOLTIP, 0);
|
||||
new StationRatingTooltipWindow(parent, st, cs);
|
||||
|
||||
@@ -1567,7 +1567,9 @@ static SettingsContainer &GetSettingsTree()
|
||||
viewports->Add(new SettingEntry("gui.show_track_reservation"));
|
||||
viewports->Add(new SettingEntry("gui.cb_distance_check"));
|
||||
viewports->Add(new SettingEntry("gui.old_depot_train_length_calc"));
|
||||
viewports->Add(new SettingEntry("gui.enable_extra_tooltips"));
|
||||
viewports->Add(new SettingEntry("gui.cm_land_tooltips_for_industries"));
|
||||
viewports->Add(new SettingEntry("gui.cm_land_tooltips_for_stations"));
|
||||
viewports->Add(new SettingEntry("gui.cm_land_tooltips_for_houses"));
|
||||
// viewports->Add(new SettingEntry("gui.polyrail_double_click"));
|
||||
}
|
||||
|
||||
|
||||
@@ -135,8 +135,6 @@ struct GUISettings {
|
||||
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
|
||||
Year coloured_news_year; ///< when does newspaper become coloured?
|
||||
bool timetable_in_ticks; ///< whether to show the timetable in ticks rather than days
|
||||
bool cm_open_vehicle_for_shared_clone;
|
||||
bool cm_open_orders_for_new_vehicles;
|
||||
bool quick_goto; ///< Allow quick access to 'goto button' in vehicle orders window
|
||||
bool auto_euro; ///< automatically switch to euro in 2002
|
||||
byte drag_signals_density; ///< many signals density
|
||||
@@ -182,7 +180,6 @@ struct GUISettings {
|
||||
|
||||
bool old_depot_train_length_calc; ///< display vehicle length in whole numbers - old style
|
||||
uint8 cb_distance_check; ///< zoning cb distance
|
||||
bool enable_extra_tooltips; ///< enable extra tooltips when hovering over various elements
|
||||
bool polyrail_double_click; ///< finish polyrail with mouse double click
|
||||
bool show_industry_forbidden_tiles; ///< higlight areas where industry placement is forbidden regardless of terrain
|
||||
bool runway_too_short_warn; ///< warn about aircrafts using too short runways
|
||||
@@ -190,6 +187,12 @@ struct GUISettings {
|
||||
uint32 powerfund_money; ///< minimum amount of money for powerfund to work
|
||||
uint16 powerfund_houses; ///< powerfunding maximum houses limit
|
||||
|
||||
bool cm_open_vehicle_for_shared_clone;
|
||||
bool cm_open_orders_for_new_vehicles;
|
||||
bool cm_land_tooltips_for_industries;
|
||||
bool cm_land_tooltips_for_stations;
|
||||
bool cm_land_tooltips_for_houses;
|
||||
|
||||
/**
|
||||
* Returns true when the user has sufficient privileges to edit newgrfs on a running game
|
||||
* @return whether the user has sufficient privileges to edit newgrfs in an existing game
|
||||
|
||||
@@ -4172,10 +4172,25 @@ strval = STR_JUST_COMMA
|
||||
proc = RedrawScreen
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.enable_extra_tooltips
|
||||
var = gui.cm_land_tooltips_for_industries
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = true
|
||||
str = STR_CONFIG_SETTING_ENABLE_EXTRA_TOOLTIPS
|
||||
str = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_INDUSTRIES
|
||||
strhelp = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_INDUSTRIES_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.cm_land_tooltips_for_stations
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = true
|
||||
str = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_STATIONS
|
||||
strhelp = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_STATIONS_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.cm_land_tooltips_for_houses
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_HOUSES
|
||||
strhelp = STR_CM_CONFIG_SETTING_LAND_TOOLTIPS_FOR_HOUSES_HELPTEXT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.polyrail_double_click
|
||||
|
||||
@@ -107,7 +107,6 @@ enum WindowClass {
|
||||
* - 0 = #ToolTipsWidgets
|
||||
*/
|
||||
WC_TOOLTIPS,
|
||||
WC_TOOLTIPS_EXTRA,
|
||||
WC_STATION_RATING_TOOLTIP,
|
||||
|
||||
/**
|
||||
@@ -710,6 +709,11 @@ enum WindowClass {
|
||||
*/
|
||||
WC_SCREENSHOT,
|
||||
|
||||
/*
|
||||
* CityMania extra windows
|
||||
*/
|
||||
CM_WC_LAND_TOOLTIPS,
|
||||
|
||||
WC_INVALID = 0xFFFF, ///< Invalid window.
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user