mirror of https://github.com/OpenTTD/OpenTTD
Compare commits
3 Commits
9998f75294
...
76dc9a3ab3
Author | SHA1 | Date |
---|---|---|
|
76dc9a3ab3 | |
|
baced00e9f | |
|
f02b13d52b |
|
@ -500,6 +500,8 @@ add_files(
|
|||
textbuf_type.h
|
||||
texteff.cpp
|
||||
texteff.hpp
|
||||
texteff_cmd.cpp
|
||||
texteff_cmd.h
|
||||
textfile_gui.cpp
|
||||
textfile_gui.h
|
||||
textfile_type.h
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include "station_cmd.h"
|
||||
#include "story_cmd.h"
|
||||
#include "subsidy_cmd.h"
|
||||
#include "texteff_cmd.h"
|
||||
#include "terraform_cmd.h"
|
||||
#include "timetable_cmd.h"
|
||||
#include "town_cmd.h"
|
||||
|
|
|
@ -372,6 +372,10 @@ enum Commands : uint8_t {
|
|||
CMD_UPDATE_LEAGUE_TABLE_ELEMENT_SCORE, ///< update the score of a league table element
|
||||
CMD_REMOVE_LEAGUE_TABLE_ELEMENT, ///< remove a league table element
|
||||
|
||||
CMD_CREATE_TEXT_EFFECT, ///< create a new text effect
|
||||
CMD_UPDATE_TEXT_EFFECT, ///< update text effect
|
||||
CMD_REMOVE_TEXT_EFFECT, ///< remove text effect
|
||||
|
||||
CMD_END, ///< Must ALWAYS be on the end of this list!! (period)
|
||||
};
|
||||
|
||||
|
|
|
@ -267,6 +267,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}jaar
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" en}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -267,6 +267,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}year
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}period{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filter:
|
||||
|
|
|
@ -268,6 +268,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}ano{
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
@ -1302,6 +1303,9 @@ STR_CONFIG_SETTING_INTEREST_RATE_HELPTEXT :A taxa de inter
|
|||
STR_CONFIG_SETTING_RUNNING_COSTS :Custos de explotación: {STRING}
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HELPTEXT :Establece o nivel de mantemento e custo de operación de vehículos e infraestrutura
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_RUNNING_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED :Velocidade de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_SPEED_HELPTEXT :Limita a cantidade de accións construtivas das IAs
|
||||
|
@ -1324,6 +1328,9 @@ STR_CONFIG_SETTING_SUBSIDY_DURATION_DISABLED :Sen subvención
|
|||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS :Custos de construción: {STRING}
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HELPTEXT :Fixa o nivel de custos de construción e compra
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_LOW :Baixo
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_MEDIUM :Medio
|
||||
STR_CONFIG_SETTING_CONSTRUCTION_COSTS_HIGH :Alto
|
||||
|
||||
STR_CONFIG_SETTING_RECESSIONS :Recesións económicas: {STRING}
|
||||
STR_CONFIG_SETTING_RECESSIONS_HELPTEXT :Se está activado, a economía pode entrar en recesión periódicamente. Durante unha recesión tódalas producións son significativamente máis baixas (volvendo ao nivel anterior cando a recesión remata)
|
||||
|
@ -2079,9 +2086,9 @@ STR_CONFIG_SETTING_DISTRIBUTION_ARMOURED_HELPTEXT :A clase de merc
|
|||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT :Xeito de distribución para outros tipos de mercadoría: {STRING}
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_DEFAULT_HELPTEXT :"Asimétrico" significa que calquera cantidade de mercadorías pode ser enviada en calquera dirección. "Manual" significa que non haberá distribución automática para estas mercadorías
|
||||
###length 3
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :simétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_MANUAL :Manual
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_ASYMMETRIC :Asimétrica
|
||||
STR_CONFIG_SETTING_DISTRIBUTION_SYMMETRIC :Simétrica
|
||||
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY :Precisión da distribución: {STRING}
|
||||
STR_CONFIG_SETTING_LINKGRAPH_ACCURACY_HELPTEXT :Canto máis alto sexa o valor, máis tempo de CPU levará o cálculo de distribución. Se leva demasiado tempo podes experimentar retraso. Se sen embargo o fixas nun valor baixo, a distribución será imprecisa, e pode que a carga non sexa enviada aos destinos que ti queres
|
||||
|
|
|
@ -739,7 +739,7 @@ STR_PLAYLIST_TOOLTIP_CLICK_TO_ADD_TRACK :{BLACK}Clique n
|
|||
STR_PLAYLIST_TOOLTIP_CLICK_TO_REMOVE_TRACK :{BLACK}Clique numa faixa para a remover da lista (apenas Personalização 1 ou Personalização 2)
|
||||
|
||||
# Highscore window
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}Melhores empresas
|
||||
STR_HIGHSCORE_TOP_COMPANIES :{BIG_FONT}{BLACK}As melhores empresas
|
||||
STR_HIGHSCORE_POSITION :{BIG_FONT}{BLACK}{COMMA}.
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_BUSINESSMAN :Negociante
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_ENTREPRENEUR :Empresário
|
||||
|
@ -749,7 +749,7 @@ STR_HIGHSCORE_PERFORMANCE_TITLE_MAGNATE :Magnata
|
|||
STR_HIGHSCORE_PERFORMANCE_TITLE_MOGUL :Grande magnata
|
||||
STR_HIGHSCORE_PERFORMANCE_TITLE_TYCOON_OF_THE_CENTURY :Magnata do século
|
||||
STR_HIGHSCORE_NAME :{PRESIDENT_NAME}, {COMPANY}
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}'{STRING}' ({COMMA})
|
||||
STR_HIGHSCORE_STATS :{BIG_FONT}"{STRING}" ({COMMA})
|
||||
STR_HIGHSCORE_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{BLACK}{COMPANY} conquista o estatuto de '{STRING}'!
|
||||
STR_HIGHSCORE_PRESIDENT_OF_COMPANY_ACHIEVES_STATUS :{BIG_FONT}{WHITE}{PRESIDENT_NAME} de {COMPANY} conquista o estatuto de '{STRING}'!
|
||||
|
||||
|
@ -3117,8 +3117,8 @@ STR_INDUSTRY_CARGOES_SELECT_INDUSTRY_TOOLTIP :{BLACK}Selecion
|
|||
# Land area window
|
||||
STR_LAND_AREA_INFORMATION_CAPTION :{WHITE}Informações do Terreno
|
||||
STR_LAND_AREA_INFORMATION_LOCATION_TOOLTIP :{BLACK}Centrar visualização na localização do mosaico. Ctrl+Clique para abrir uma nova janela de visualização nesse mosaico.
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo para limpar: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo para limpar: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR_N_A :{BLACK}Custo de desobstrução: {LTBLUE}N/D
|
||||
STR_LAND_AREA_INFORMATION_COST_TO_CLEAR :{BLACK}Custo de desobstrução: {RED}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_REVENUE_WHEN_CLEARED :{BLACK}Receitas apuradas: {LTBLUE}{CURRENCY_LONG}
|
||||
STR_LAND_AREA_INFORMATION_OWNER_N_A :N/D
|
||||
STR_LAND_AREA_INFORMATION_OWNER :{BLACK}Proprietário: {LTBLUE}{STRING}
|
||||
|
@ -3126,7 +3126,7 @@ STR_LAND_AREA_INFORMATION_ROAD_OWNER :{BLACK}Dono da
|
|||
STR_LAND_AREA_INFORMATION_TRAM_OWNER :{BLACK}Dono da linha de eléctrico: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_RAIL_OWNER :{BLACK}Dono da linha férrea: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY :{BLACK}Autoridade local: {LTBLUE}{STRING}
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhum
|
||||
STR_LAND_AREA_INFORMATION_LOCAL_AUTHORITY_NONE :Nenhuma
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_COORDS :{BLACK}Coordenadas: {LTBLUE}{NUM} x {NUM} x {NUM}
|
||||
STR_LAND_AREA_INFORMATION_LANDINFO_INDEX :{BLACK}Índice do mosaico: {LTBLUE}{NUM} ({HEX})
|
||||
STR_LAND_AREA_INFORMATION_BUILD_DATE :{BLACK}Construído/renovado: {LTBLUE}{DATE_LONG}
|
||||
|
@ -3685,9 +3685,9 @@ STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED_WINTER :{BLACK}No inver
|
|||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED_GENERAL :{ORANGE}{STRING}{GREEN} fo{G 0 i i i ram ram} entregue{G 0 "" "" "" s s}
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_REQUIRED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{RED} (ainda necessário)
|
||||
STR_TOWN_VIEW_CARGO_FOR_TOWNGROWTH_DELIVERED :{ORANGE}{CARGO_TINY} / {CARGO_LONG}{GREEN} (entregue)
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}Localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}Localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS}
|
||||
STR_TOWN_VIEW_TOWN_GROWS_EVERY_FUNDED :{BLACK}A localidade cresce a cada {ORANGE}{UNITS_DAYS_OR_SECONDS} (financiada)
|
||||
STR_TOWN_VIEW_TOWN_GROW_STOPPED :{BLACK}A localidade {RED}não{BLACK} está a crescer
|
||||
STR_TOWN_VIEW_NOISE_IN_TOWN :{BLACK}Limite de ruído na localidade: {ORANGE}{COMMA}{BLACK} máx: {ORANGE}{COMMA}
|
||||
STR_TOWN_VIEW_CENTER_TOOLTIP :{BLACK}Centrar visualização na localização da localidade. Ctrl+Clique para abrir um novo visualizador na localização da localidade
|
||||
STR_TOWN_VIEW_LOCAL_AUTHORITY_BUTTON :{BLACK}Autoridade Local
|
||||
|
@ -3700,7 +3700,7 @@ STR_TOWN_VIEW_EXPAND_BUILDINGS_BUTTON :{BLACK}Expandir
|
|||
STR_TOWN_VIEW_EXPAND_BUILDINGS_TOOLTIP :{BLACK}Aumentar os edifícios da localidade
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_BUTTON :{BLACK}Expandir estradas
|
||||
STR_TOWN_VIEW_EXPAND_ROADS_TOOLTIP :{BLACK}Aumentar as estradas da localidade
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Apagar
|
||||
STR_TOWN_VIEW_DELETE_BUTTON :{BLACK}Remover
|
||||
STR_TOWN_VIEW_DELETE_TOOLTIP :{BLACK}Remover completamente esta localidade
|
||||
|
||||
STR_TOWN_VIEW_RENAME_TOWN_BUTTON :Renomear Localidade
|
||||
|
@ -3943,7 +3943,7 @@ STR_FINANCES_INFRASTRUCTURE_BUTTON :{BLACK}Infraest
|
|||
STR_COMPANY_VIEW_CAPTION :{WHITE}{COMPANY} {BLACK}{COMPANY_NUM}
|
||||
STR_COMPANY_VIEW_PRESIDENT_MANAGER_TITLE :{WHITE}{PRESIDENT_NAME}{}{GOLD}(Presidente)
|
||||
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurado: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE :{GOLD}Inaugurada em: {WHITE}{NUM}
|
||||
STR_COMPANY_VIEW_INAUGURATED_TITLE_WALLCLOCK :{GOLD}Inaugurada: {WHITE}{NUM} (período {NUM})
|
||||
STR_COMPANY_VIEW_COLOUR_SCHEME_TITLE :{GOLD}Cores:
|
||||
STR_COMPANY_VIEW_VEHICLES_TITLE :{GOLD}Veículos:
|
||||
|
|
|
@ -268,6 +268,7 @@ STR_UNITS_YEARS :{NUM}{NBSP}año
|
|||
STR_UNITS_PERIODS :{NUM}{NBSP}período{P "" s}
|
||||
|
||||
STR_LIST_SEPARATOR :,{SPACE}
|
||||
STR_TRUNCATION_ELLIPSIS :...
|
||||
|
||||
# Common window strings
|
||||
STR_LIST_FILTER_TITLE :{BLACK}Filtrar:
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "../station_cmd.h"
|
||||
#include "../story_cmd.h"
|
||||
#include "../subsidy_cmd.h"
|
||||
#include "../texteff_cmd.h"
|
||||
#include "../terraform_cmd.h"
|
||||
#include "../timetable_cmd.h"
|
||||
#include "../town_cmd.h"
|
||||
|
|
|
@ -206,6 +206,7 @@ add_files(
|
|||
script_subsidylist.hpp
|
||||
script_testmode.hpp
|
||||
script_text.hpp
|
||||
script_text_effect.hpp
|
||||
script_tile.hpp
|
||||
script_tilelist.hpp
|
||||
script_town.hpp
|
||||
|
@ -278,6 +279,7 @@ add_files(
|
|||
script_subsidylist.cpp
|
||||
script_testmode.cpp
|
||||
script_text.cpp
|
||||
script_text_effect.cpp
|
||||
script_tile.cpp
|
||||
script_tilelist.cpp
|
||||
script_town.cpp
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_text_effect.cpp Implementation of ScriptTextEffect with multiplayer support. */
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_text_effect.hpp"
|
||||
#include "script_error.hpp"
|
||||
#include "script_map.hpp"
|
||||
#include "../script_instance.hpp"
|
||||
#include "../../texteff.hpp"
|
||||
#include "../../strings_func.h"
|
||||
#include "../../tile_map.h"
|
||||
#include "../../command_func.h"
|
||||
#include "../../texteff_cmd.h"
|
||||
|
||||
#include "../../safeguards.h"
|
||||
|
||||
/* static */ TextEffectID ScriptTextEffect::CreateAtPosition(SQInteger x, SQInteger y, Text *text, ScriptTextEffectMode mode)
|
||||
{
|
||||
ScriptObjectRef counter(text);
|
||||
|
||||
EnforceDeityMode(false);
|
||||
EnforcePrecondition(false, text != nullptr);
|
||||
EnforcePrecondition(false, !text->GetEncodedText().empty());
|
||||
EnforcePrecondition(false, mode == TE_RISING || mode == TE_STATIC);
|
||||
|
||||
return ScriptObject::Command<CMD_CREATE_TEXT_EFFECT>::Do(&ScriptInstance::DoCommandReturnTextEffectID, x, y, (TextEffectMode)mode, text->GetEncodedText());
|
||||
}
|
||||
|
||||
/* static */ TextEffectID ScriptTextEffect::Create(TileIndex tile, Text *text, ScriptTextEffectMode mode)
|
||||
{
|
||||
EnforcePrecondition(false, ScriptMap::IsValidTile(tile));
|
||||
|
||||
int x = TileX(tile) * TILE_SIZE + TILE_SIZE / 2;
|
||||
int y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
|
||||
|
||||
return CreateAtPosition(x, y, text, mode);
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTextEffect::Update(TextEffectID te_id, Text *text)
|
||||
{
|
||||
ScriptObjectRef counter(text);
|
||||
|
||||
EnforceDeityMode(false);
|
||||
EnforcePrecondition(false, te_id != INVALID_TE_ID);
|
||||
EnforcePrecondition(false, text != nullptr);
|
||||
EnforcePrecondition(false, !text->GetEncodedText().empty());
|
||||
|
||||
return ScriptObject::Command<CMD_UPDATE_TEXT_EFFECT>::Do(te_id, text->GetEncodedText());
|
||||
}
|
||||
|
||||
/* static */ bool ScriptTextEffect::Remove(TextEffectID te_id)
|
||||
{
|
||||
EnforceDeityMode(false);
|
||||
EnforcePrecondition(false, te_id != INVALID_TE_ID);
|
||||
|
||||
return ScriptObject::Command<CMD_REMOVE_TEXT_EFFECT>::Do(te_id);
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file script_text_effect.hpp Everything to display animated text in the game world. */
|
||||
|
||||
#ifndef SCRIPT_TEXT_EFFECT_HPP
|
||||
#define SCRIPT_TEXT_EFFECT_HPP
|
||||
|
||||
#include "script_object.hpp"
|
||||
#include "script_text.hpp"
|
||||
#include "../../texteff.hpp"
|
||||
|
||||
/**
|
||||
* Class that handles text effect display in the game world.
|
||||
* @api game
|
||||
*/
|
||||
class ScriptTextEffect : public ScriptObject {
|
||||
public:
|
||||
/**
|
||||
* Text effect animation modes.
|
||||
*/
|
||||
enum ScriptTextEffectMode {
|
||||
TE_RISING = ::TE_RISING, ///< Text slowly rises upwards
|
||||
TE_STATIC = ::TE_STATIC, ///< Text stays in place
|
||||
};
|
||||
|
||||
/**
|
||||
* Create animated text at a tile location.
|
||||
* @param tile The tile where to show the text.
|
||||
* @param text The text to display.
|
||||
* @param mode The animation mode to use.
|
||||
* @return True if the text effect was created successfully.
|
||||
*/
|
||||
static TextEffectID Create(TileIndex tile, Text *text, ScriptTextEffectMode mode);
|
||||
|
||||
/**
|
||||
* Create animated text at the specified location.
|
||||
* @param x X coordinate in the game world.
|
||||
* @param y Y coordinate in the game world.
|
||||
* @param text The text to display.
|
||||
* @param mode The animation mode to use.
|
||||
* @return True if the text effect was created successfully.
|
||||
*/
|
||||
static TextEffectID CreateAtPosition(SQInteger x, SQInteger y, Text *text, ScriptTextEffectMode mode);
|
||||
|
||||
/**
|
||||
* Update animated text
|
||||
* @param te_id Text effect ID.
|
||||
* @param text The text to update
|
||||
* @return True if the text effect was updated successfully
|
||||
*/
|
||||
static bool Update(TextEffectID te_id, Text *text);
|
||||
|
||||
/**
|
||||
* Update animated text
|
||||
* @param te_id Text effect ID.
|
||||
* @return True if the text effect was removed successfully
|
||||
*/
|
||||
static bool Remove(TextEffectID te_id);
|
||||
};
|
||||
|
||||
#endif /* SCRIPT_TEXT_EFFECT_HPP */
|
|
@ -29,6 +29,7 @@
|
|||
#include "../fileio_func.h"
|
||||
#include "../league_type.h"
|
||||
#include "../misc/endian_buffer.hpp"
|
||||
#include "../texteff.hpp"
|
||||
|
||||
#include "../safeguards.h"
|
||||
|
||||
|
@ -315,6 +316,10 @@ void ScriptInstance::CollectGarbage()
|
|||
instance.engine->InsertResult(EndianBufferReader::ToValue<LeagueTableID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
/* static */ void ScriptInstance::DoCommandReturnTextEffectID(ScriptInstance *instance)
|
||||
{
|
||||
instance->engine->InsertResult(EndianBufferReader::ToValue<TextEffectID>(ScriptObject::GetLastCommandResData()));
|
||||
}
|
||||
|
||||
ScriptStorage *ScriptInstance::GetStorage()
|
||||
{
|
||||
|
|
|
@ -143,6 +143,11 @@ public:
|
|||
*/
|
||||
static void DoCommandReturnLeagueTableElementID(ScriptInstance &instance);
|
||||
|
||||
/**
|
||||
* Return a TextEffectID reply for a DoCommand.
|
||||
*/
|
||||
static void DoCommandReturnTextEffectID(ScriptInstance *instance);
|
||||
|
||||
/**
|
||||
* Get the controller attached to the instance.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file texteff_cmd.cpp Command handling for text effects */
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "command_func.h"
|
||||
#include "texteff.hpp"
|
||||
#include "strings_func.h"
|
||||
#include "tile_map.h"
|
||||
#include "texteff_cmd.h"
|
||||
|
||||
#include "table/strings.h"
|
||||
|
||||
#include "safeguards.h"
|
||||
#include "landscape.h"
|
||||
|
||||
/**
|
||||
* Show a text effect at the specified location.
|
||||
* @param flags operation to perform
|
||||
* @param x X coordinate in the game
|
||||
* @param y Y coordinate in the game
|
||||
* @param mode The animation mode to use
|
||||
* @param text The text to display
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
std::tuple<CommandCost, TextEffectID> CmdCreateTextEffect(DoCommandFlags flags, int32_t x, int32_t y, TextEffectMode mode, const EncodedString &text)
|
||||
{
|
||||
if (text.empty()) return { CMD_ERROR, INVALID_TE_ID };
|
||||
if (mode != TE_RISING && mode != TE_STATIC) return { CMD_ERROR, INVALID_TE_ID };
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
Point pt = RemapCoords2(x, y);
|
||||
EncodedString encoded_text = text;
|
||||
TextEffectID te_id;
|
||||
|
||||
if (mode == TE_RISING) {
|
||||
te_id = AddTextEffect(std::move(encoded_text), pt.x, pt.y, Ticks::DAY_TICKS, TE_RISING);
|
||||
} else {
|
||||
te_id = AddTextEffect(std::move(encoded_text), pt.x, pt.y, 0, TE_STATIC);
|
||||
}
|
||||
|
||||
return { CommandCost(), te_id };
|
||||
}
|
||||
|
||||
return { CommandCost(), INVALID_TE_ID };
|
||||
}
|
||||
|
||||
CommandCost CmdUpdateTextEffect(DoCommandFlags flags, TextEffectID te_id, const EncodedString &text)
|
||||
{
|
||||
if (te_id == INVALID_TE_ID) return CMD_ERROR;
|
||||
if (text.empty()) return CMD_ERROR;
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
EncodedString encoded_text = text;
|
||||
UpdateTextEffect(te_id, std::move(encoded_text));
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
CommandCost CmdRemoveTextEffect(DoCommandFlags flags, TextEffectID te_id)
|
||||
{
|
||||
if (te_id == INVALID_TE_ID) return CMD_ERROR;
|
||||
|
||||
if (flags.Test(DoCommandFlag::Execute)) {
|
||||
RemoveTextEffect(te_id);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
* This file is part of OpenTTD.
|
||||
* OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
* OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
* See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/** @file texteff_cmd.h Command declarations for text effects */
|
||||
|
||||
#ifndef TEXTEFF_CMD_H
|
||||
#define TEXTEFF_CMD_H
|
||||
|
||||
#include "command_type.h"
|
||||
#include "texteff.hpp"
|
||||
|
||||
std::tuple<CommandCost, TextEffectID> CmdCreateTextEffect(DoCommandFlags flags, int32_t x, int32_t y, TextEffectMode mode, const EncodedString &text);
|
||||
CommandCost CmdUpdateTextEffect(DoCommandFlags flags, TextEffectID te_id, const EncodedString &text);
|
||||
CommandCost CmdRemoveTextEffect(DoCommandFlags flags, TextEffectID te_id);
|
||||
|
||||
DEF_CMD_TRAIT(CMD_CREATE_TEXT_EFFECT, CmdCreateTextEffect, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_UPDATE_TEXT_EFFECT, CmdUpdateTextEffect, CommandFlags({CommandFlag::Deity, CommandFlag::StrCtrl}), CMDT_OTHER_MANAGEMENT)
|
||||
DEF_CMD_TRAIT(CMD_REMOVE_TEXT_EFFECT, CmdRemoveTextEffect, CommandFlag::Deity, CMDT_OTHER_MANAGEMENT)
|
||||
|
||||
#endif /* TEXTEFF_CMD_H */
|
Loading…
Reference in New Issue