本文整理汇总了C++中SetDParam函数的典型用法代码示例。如果您正苦于以下问题:C++ SetDParam函数的具体用法?C++ SetDParam怎么用?C++ SetDParam使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetDParam函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CcGiveMoney
void CcGiveMoney(const CommandCost &result, TileIndex tile, uint32 p1, uint32 p2)
{
if (result.Failed() || !_settings_game.economy.give_money) return;
/* Inform the company of the action of one of its clients (controllers). */
char msg[64];
SetDParam(0, p2);
GetString(msg, STR_COMPANY_NAME, lastof(msg));
if (!_network_server) {
NetworkClientSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, p1);
} else {
NetworkServerSendChat(NETWORK_ACTION_GIVE_MONEY, DESTTYPE_TEAM, p2, msg, CLIENT_ID_SERVER, p1);
}
}
示例2: UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
Dimension d;
switch (widget) {
/* Left and right should have same sizing. */
case WID_S_LEFT:
case WID_S_RIGHT: {
SetDParamMaxValue(0, MAX_YEAR * DAYS_IN_YEAR);
d = GetStringBoundingBox(STR_WHITE_DATE_LONG);
int64 max_money = UINT32_MAX;
const Company *c;
FOR_ALL_COMPANIES(c) max_money = max<int64>(c->money, max_money);
SetDParam(0, 100LL * max_money);
d = maxdim(d, GetStringBoundingBox(STR_COMPANY_MONEY));
break;
}
case WID_S_MIDDLE:
d = GetStringBoundingBox(STR_STATUSBAR_AUTOSAVE);
d = maxdim(d, GetStringBoundingBox(STR_STATUSBAR_PAUSED));
if (Company::IsValidID(_local_company)) {
SetDParam(0, _local_company);
d = maxdim(d, GetStringBoundingBox(STR_STATUSBAR_COMPANY_NAME));
}
break;
default:
return;
}
d.width += padding.width;
d.height += padding.height;
*size = maxdim(d, *size);
}
示例3: DrawRailWagonPurchaseInfo
/* Draw rail wagon specific details */
static int DrawRailWagonPurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
{
const Engine *e = Engine::Get(engine_number);
/* Purchase cost */
SetDParam(0, e->GetCost());
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
y += FONT_HEIGHT_NORMAL;
/* Wagon weight - (including cargo) */
uint weight = e->GetDisplayWeight();
SetDParam(0, weight);
uint cargo_weight = (e->CanCarryCargo() ? CargoSpec::Get(e->GetDefaultCargoType())->weight * GetTotalCapacityOfArticulatedParts(engine_number) / 16 : 0);
SetDParam(1, cargo_weight + weight);
DrawString(left, right, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT);
y += FONT_HEIGHT_NORMAL;
/* Wagon speed limit, displayed if above zero */
if (_settings_game.vehicle.wagon_speed_limits) {
uint max_speed = e->GetDisplayMaxSpeed();
if (max_speed > 0) {
SetDParam(0, max_speed);
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED);
y += FONT_HEIGHT_NORMAL;
}
}
/* Running cost */
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
}
return y;
}
示例4: DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case MTSW_LIST_LEFT: {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
int y = r.top + WD_FRAMERECT_TOP;
for (uint i = 0; i < NUM_SONGS_AVAILABLE; i++) {
const char *song_name = GetSongName(i);
if (StrEmpty(song_name)) continue;
SetDParam(0, GetTrackNumber(i));
SetDParam(1, 2);
SetDParamStr(2, song_name);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
y += FONT_HEIGHT_SMALL;
}
break;
}
case MTSW_LIST_RIGHT: {
GfxFillRect(r.left + 1, r.top + 1, r.right - 1, r.bottom - 1, PC_BLACK);
int y = r.top + WD_FRAMERECT_TOP;
for (const byte *p = _playlists[_settings_client.music.playlist]; *p != 0; p++) {
uint i = *p - 1;
SetDParam(0, GetTrackNumber(i));
SetDParam(1, 2);
SetDParamStr(2, GetSongName(i));
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_PLAYLIST_TRACK_NAME);
y += FONT_HEIGHT_SMALL;
}
break;
}
}
}
示例5: UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
if (widget == WID_MH_BACKGROUND) {
this->line_height = FONT_HEIGHT_NORMAL + 2;
resize->height = this->line_height;
/* Months are off-by-one, so it's actually 8. Not using
* month 12 because the 1 is usually less wide. */
SetDParam(0, ConvertYMDToDate(ORIGINAL_MAX_YEAR, 7, 30));
this->date_width = GetStringBoundingBox(STR_SHORT_DATE).width;
size->height = 4 * resize->height + this->top_spacing + this->bottom_spacing; // At least 4 lines are visible.
size->width = max(200u, size->width); // At least 200 pixels wide.
}
}
示例6: ShipArrivesAt
static void ShipArrivesAt(const Vehicle *v, Station *st)
{
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
st->had_vehicle_of_type |= HVOT_SHIP;
SetDParam(0, st->index);
AddVehicleNewsItem(
STR_NEWS_FIRST_SHIP_ARRIVAL,
(v->owner == _local_company) ? NS_ARRIVAL_COMPANY : NS_ARRIVAL_OTHER,
v->index,
st->index
);
AI::NewEvent(v->owner, new AIEventStationFirstVehicle(st->index, v->index));
}
}
示例7: OnClick
virtual void OnClick(Point pt, int widget, int click_count)
{
const NWidgetBase *wid = this->GetWidget<NWidgetBase>(CW_PANEL);
uint btn = (pt.y - wid->pos_y - WD_FRAMERECT_TOP - this->header_height) / (FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL);
uint x = pt.x - wid->pos_x;
bool rtl = _current_text_dir == TD_RTL;
if (rtl) x = wid->current_x - x;
if (btn >= lengthof(_cheats_ui)) return;
const CheatEntry *ce = &_cheats_ui[btn];
int value = (int32)ReadValue(ce->variable, ce->type);
int oldvalue = value;
if (btn == CHT_CHANGE_DATE && x >= 40) {
/* Click at the date text directly. */
SetDParam(0, value);
ShowQueryString(STR_JUST_INT, STR_CHEAT_CHANGE_DATE_QUERY_CAPT, 8, this, CS_NUMERAL, QSF_ACCEPT_UNCHANGED);
return;
}
/* Not clicking a button? */
if (!IsInsideMM(x, 20, 40)) return;
*ce->been_used = true;
switch (ce->type) {
case SLE_BOOL:
value ^= 1;
if (ce->proc != NULL) ce->proc(value, 0);
break;
default:
/* Take whatever the function returns */
value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1);
/* The first cheat (money), doesn't return a different value. */
if (value != oldvalue || btn == CHT_MONEY) this->clicked = btn * 2 + 1 + ((x >= 30) != rtl ? 1 : 0);
break;
}
if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
this->flags4 |= WF_TIMEOUT_BEGIN;
this->SetDirty();
}
示例8: DrawWidget
virtual void DrawWidget(const Rect &r, int widget) const
{
switch (widget) {
case AIL_WIDGET_LIST: {
/* Draw a list of all available AIs. */
int y = this->GetWidget<NWidgetBase>(AIL_WIDGET_LIST)->pos_y;
/* First AI in the list is hardcoded to random */
if (this->vscroll->IsVisible(0)) {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_LEFT, y + WD_MATRIX_TOP, STR_AI_CONFIG_RANDOM_AI, this->selected == -1 ? TC_WHITE : TC_BLACK);
y += this->line_height;
}
AIInfoList::const_iterator it = this->ai_info_list->begin();
for (int i = 1; it != this->ai_info_list->end(); i++, it++) {
if (this->vscroll->IsVisible(i)) {
DrawString(r.left + WD_MATRIX_LEFT, r.right - WD_MATRIX_RIGHT, y + WD_MATRIX_TOP, (*it).second->GetName(), (this->selected == i - 1) ? TC_WHITE : TC_BLACK);
y += this->line_height;
}
}
break;
}
case AIL_WIDGET_INFO_BG: {
AIInfo *selected_info = NULL;
AIInfoList::const_iterator it = this->ai_info_list->begin();
for (int i = 1; selected_info == NULL && it != this->ai_info_list->end(); i++, it++) {
if (this->selected == i - 1) selected_info = (*it).second;
}
/* Some info about the currently selected AI. */
if (selected_info != NULL) {
int y = r.top + WD_FRAMERECT_TOP;
SetDParamStr(0, selected_info->GetAuthor());
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_AUTHOR);
y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
SetDParam(0, selected_info->GetVersion());
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_VERSION);
y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
if (selected_info->GetURL() != NULL) {
SetDParamStr(0, selected_info->GetURL());
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, STR_AI_LIST_URL);
y += FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL;
}
SetDParamStr(0, selected_info->GetDescription());
DrawStringMultiLine(r.left + WD_FRAMETEXT_LEFT, r.right - WD_FRAMETEXT_RIGHT, y, r.bottom - WD_FRAMERECT_BOTTOM, STR_JUST_RAW_STRING, TC_BLACK);
}
break;
}
}
}
示例9: DrawShipPurchaseInfo
/* Draw ship specific details */
static int DrawShipPurchaseInfo(int left, int right, int y, EngineID engine_number, bool refittable)
{
const Engine *e = Engine::Get(engine_number);
/* Purchase cost - Max speed */
uint raw_speed = e->GetDisplayMaxSpeed();
uint ocean_speed = e->u.ship.ApplyWaterClassSpeedFrac(raw_speed, true);
uint canal_speed = e->u.ship.ApplyWaterClassSpeedFrac(raw_speed, false);
SetDParam(0, e->GetCost());
if (ocean_speed == canal_speed) {
SetDParam(1, ocean_speed);
DrawString(left, right, y, STR_PURCHASE_INFO_COST_SPEED);
y += FONT_HEIGHT_NORMAL;
} else {
DrawString(left, right, y, STR_PURCHASE_INFO_COST);
y += FONT_HEIGHT_NORMAL;
SetDParam(0, ocean_speed);
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_OCEAN);
y += FONT_HEIGHT_NORMAL;
SetDParam(0, canal_speed);
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_CANAL);
y += FONT_HEIGHT_NORMAL;
}
/* Cargo type + capacity */
SetDParam(0, e->GetDefaultCargoType());
SetDParam(1, e->GetDisplayDefaultCapacity());
SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
y += FONT_HEIGHT_NORMAL;
/* Running cost */
SetDParam(0, e->GetRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
return y;
}
示例10: GetAircraftEngineInfoString
static StringID GetAircraftEngineInfoString(const Engine *e)
{
CargoID cargo = e->GetDefaultCargoType();
uint16 mail_capacity;
uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
uint16 range = e->GetRange();
uint i = 0;
SetDParam(i++, e->GetCost());
SetDParam(i++, e->GetDisplayMaxSpeed());
if (range > 0) SetDParam(i++, range);
SetDParam(i++, cargo);
SetDParam(i++, capacity);
if (mail_capacity > 0) {
SetDParam(i++, CT_MAIL);
SetDParam(i++, mail_capacity);
SetDParam(i++, e->GetRunningCost());
return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_RANGE_CAPACITY_CAPACITY_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_CAPACITY_RUNCOST;
} else {
SetDParam(i++, e->GetRunningCost());
return range > 0 ? STR_ENGINE_PREVIEW_COST_MAX_SPEED_RANGE_CAPACITY_RUNCOST : STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
}
}
示例11: packet
void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr)
{
/* Just a fail-safe.. should never happen */
if (!_network_udp_server) return;
Packet packet(PACKET_UDP_SERVER_DETAIL_INFO);
/* Send the amount of active companies */
packet.Send_uint8 (NETWORK_COMPANY_INFO_VERSION);
packet.Send_uint8 ((uint8)Company::GetNumItems());
/* Fetch the latest version of the stats */
NetworkCompanyStats company_stats[MAX_COMPANIES];
NetworkPopulateCompanyStats(company_stats);
/* The minimum company information "blob" size. */
static const uint MIN_CI_SIZE = 54;
uint max_cname_length = NETWORK_COMPANY_NAME_LENGTH;
if (Company::GetNumItems() * (MIN_CI_SIZE + NETWORK_COMPANY_NAME_LENGTH) >= (uint)SEND_MTU - packet.size) {
/* Assume we can at least put the company information in the packets. */
assert(Company::GetNumItems() * MIN_CI_SIZE < (uint)SEND_MTU - packet.size);
/* At this moment the company names might not fit in the
* packet. Check whether that is really the case. */
for (;;) {
int free = SEND_MTU - packet.size;
Company *company;
FOR_ALL_COMPANIES(company) {
char company_name[NETWORK_COMPANY_NAME_LENGTH];
SetDParam(0, company->index);
GetString(company_name, STR_COMPANY_NAME, company_name + max_cname_length - 1);
free -= MIN_CI_SIZE;
free -= (int)strlen(company_name);
}
if (free >= 0) break;
/* Try again, with slightly shorter strings. */
assert(max_cname_length > 0);
max_cname_length--;
}
}
示例12: UpdateSignEditWindow
void UpdateSignEditWindow(const Sign *si)
{
char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0'
/* Display an empty string when the sign hasnt been edited yet */
if (si->name != NULL) {
SetDParam(0, si->index);
GetString(this->edit_str_buf, STR_SIGN_NAME, last_of);
} else {
GetString(this->edit_str_buf, STR_EMPTY, last_of);
}
*last_of = '\0';
this->cur_sign = si->index;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, this->max_chars);
this->SetWidgetDirty(WID_QES_TEXT);
this->SetFocusedWidget(WID_QES_TEXT);
}
示例13: GetAircraftEngineInfoString
static StringID GetAircraftEngineInfoString(const Engine *e)
{
CargoID cargo = e->GetDefaultCargoType();
uint16 mail_capacity;
uint capacity = e->GetDisplayDefaultCapacity(&mail_capacity);
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayMaxSpeed());
SetDParam(2, cargo);
SetDParam(3, capacity);
if (mail_capacity > 0) {
SetDParam(4, CT_MAIL);
SetDParam(5, mail_capacity);
SetDParam(6, e->GetRunningCost());
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_CAPACITY_RUNCOST;
} else {
SetDParam(4, e->GetRunningCost());
return STR_ENGINE_PREVIEW_COST_MAX_SPEED_CAPACITY_RUNCOST;
}
}
示例14: UpdateWidgetSize
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{
if (widget != CW_PANEL) return;
uint width = 0;
for (int i = 0; i != lengthof(_cheats_ui); i++) {
const CheatEntry *ce = &_cheats_ui[i];
switch (ce->type) {
case SLE_BOOL:
SetDParam(0, STR_CONFIG_SETTING_ON);
width = max(width, GetStringBoundingBox(ce->str).width);
SetDParam(0, STR_CONFIG_SETTING_OFF);
width = max(width, GetStringBoundingBox(ce->str).width);
break;
default:
switch (ce->str) {
/* Display date for change date cheat */
case STR_CHEAT_CHANGE_DATE:
SetDParam(0, ConvertYMDToDate(MAX_YEAR, 11, 31));
width = max(width, GetStringBoundingBox(ce->str).width);
break;
/* Draw coloured flag for change company cheat */
case STR_CHEAT_CHANGE_COMPANY:
SetDParam(0, 15);
width = max(width, GetStringBoundingBox(ce->str).width + 10 + 10);
break;
/* Set correct string for switch climate cheat */
case STR_CHEAT_SWITCH_CLIMATE:
for (StringID i = STR_CHEAT_SWITCH_CLIMATE_TEMPERATE_LANDSCAPE; i <= STR_CHEAT_SWITCH_CLIMATE_TOYLAND_LANDSCAPE; i++) {
SetDParam(0, i);
width = max(width, GetStringBoundingBox(ce->str).width);
}
break;
default:
SetDParam(0, INT64_MAX);
width = max(width, GetStringBoundingBox(ce->str).width);
break;
}
break;
}
}
size->width = width + 50 /* stuff on the left */ + 10 /* extra spacing on right */;
this->header_height = GetStringHeight(STR_CHEATS_WARNING, size->width - WD_FRAMERECT_LEFT - WD_FRAMERECT_RIGHT) + WD_PAR_VSEP_WIDE;
size->height = this->header_height + WD_FRAMERECT_TOP + WD_PAR_VSEP_NORMAL + WD_FRAMERECT_BOTTOM + (FONT_HEIGHT_NORMAL + WD_PAR_VSEP_NORMAL) * lengthof(_cheats_ui);
}
示例15: DrawRailEnginePurchaseInfo
/* Draw locomotive specific details */
static int DrawRailEnginePurchaseInfo(int left, int right, int y, EngineID engine_number, const RailVehicleInfo *rvi)
{
const Engine *e = Engine::Get(engine_number);
/* Purchase Cost - Engine weight */
SetDParam(0, e->GetCost());
SetDParam(1, e->GetDisplayWeight());
DrawString(left, right, y, STR_PURCHASE_INFO_COST_WEIGHT);
y += FONT_HEIGHT_NORMAL;
/* Max speed - Engine power */
SetDParam(0, e->GetDisplayMaxSpeed());
SetDParam(1, e->GetPower());
DrawString(left, right, y, STR_PURCHASE_INFO_SPEED_POWER);
y += FONT_HEIGHT_NORMAL;
/* Max tractive effort - not applicable if old acceleration or maglev */
if (_settings_game.vehicle.train_acceleration_model != AM_ORIGINAL && GetRailTypeInfo(rvi->railtype)->acceleration_type != 2) {
SetDParam(0, e->GetDisplayMaxTractiveEffort());
DrawString(left, right, y, STR_PURCHASE_INFO_MAX_TE);
y += FONT_HEIGHT_NORMAL;
}
/* Running cost */
if (rvi->running_cost_class != INVALID_PRICE) {
SetDParam(0, e->GetRunningCost());
DrawString(left, right, y, STR_PURCHASE_INFO_RUNNINGCOST);
y += FONT_HEIGHT_NORMAL;
}
/* Powered wagons power - Powered wagons extra weight */
if (rvi->pow_wag_power != 0) {
SetDParam(0, rvi->pow_wag_power);
SetDParam(1, rvi->pow_wag_weight);
DrawString(left, right, y, STR_PURCHASE_INFO_PWAGPOWER_PWAGWEIGHT);
y += FONT_HEIGHT_NORMAL;
}
return y;
}