(svn r23827) -Feature [FS#4992]: [NoGo] Allow to chose the goal question window's title from a (small) set of options

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
rubidium 13 years ago
parent 70c7fbd90e
commit 9f162e7115

@ -130,14 +130,17 @@ CommandCost CmdGoalQuestion(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
{
uint16 uniqueid = (GoalType)GB(p1, 0, 16);
CompanyID company = (CompanyID)GB(p1, 16, 8);
byte type = GB(p1, 24, 8);
if (_current_company != OWNER_DEITY) return CMD_ERROR;
if (StrEmpty(text)) return CMD_ERROR;
if (company != INVALID_COMPANY && !Company::IsValidID(company)) return CMD_ERROR;
if (CountBits(p2) < 1 || CountBits(p2) > 3) return CMD_ERROR;
if (p2 >= (1 << GOAL_QUESTION_BUTTON_COUNT)) return CMD_ERROR;
if (type >= GOAL_QUESTION_TYPE_COUNT) return CMD_ERROR;
if (flags & DC_EXEC) {
if (company == _local_company || (company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowGoalQuestion(uniqueid, p2, text);
if (company == _local_company || (company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowGoalQuestion(uniqueid, type, p2, text);
}
return CommandCost();

@ -258,13 +258,15 @@ struct GoalQuestionWindow : Window {
char *question;
int buttons;
int button[3];
byte type;
GoalQuestionWindow(const WindowDesc *desc, WindowNumber window_number, uint32 button_mask, const char *question) : Window()
GoalQuestionWindow(const WindowDesc *desc, WindowNumber window_number, byte type, uint32 button_mask, const char *question) : Window(), type(type)
{
assert(type < GOAL_QUESTION_TYPE_COUNT);
this->question = strdup(question);
/* Figure out which buttons we have to enable */
int bit;
uint bit;
int n = 0;
FOR_EACH_SET_BIT(bit, button_mask) {
if (bit >= GOAL_QUESTION_BUTTON_COUNT) break;
@ -287,6 +289,10 @@ struct GoalQuestionWindow : Window {
virtual void SetStringParameters(int widget) const
{
switch (widget) {
case WID_GQ_CAPTION:
SetDParam(0, STR_GOAL_QUESTION_CAPTION_QUESTION + this->type);
break;
case WID_GQ_BUTTON_1:
SetDParam(0, STR_GOAL_QUESTION_BUTTON_CANCEL + this->button[0]);
break;
@ -341,7 +347,7 @@ struct GoalQuestionWindow : Window {
static const NWidgetPart _nested_goal_question_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_LIGHT_BLUE),
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE), SetDataTip(STR_GOAL_QUESTION_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_CAPTION, COLOUR_LIGHT_BLUE, WID_GQ_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
EndContainer(),
NWidget(WWT_PANEL, COLOUR_LIGHT_BLUE),
NWidget(WWT_EMPTY, INVALID_COLOUR, WID_GQ_QUESTION), SetMinimalSize(300, 0), SetPadding(8, 8, 8, 8), SetFill(1, 0),
@ -371,7 +377,7 @@ static const WindowDesc _goal_question_list_desc(
);
void ShowGoalQuestion(uint16 id, uint32 button_mask, const char *question)
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question)
{
new GoalQuestionWindow(&_goal_question_list_desc, id, button_mask, question);
new GoalQuestionWindow(&_goal_question_list_desc, id, type, button_mask, question);
}

@ -14,9 +14,8 @@
#include "core/enum_type.hpp"
enum {
GOAL_QUESTION_BUTTON_COUNT = 18, ///< Amount of buttons available.
};
static const uint32 GOAL_QUESTION_BUTTON_COUNT = 18; ///< Amount of buttons available.
static const byte GOAL_QUESTION_TYPE_COUNT = 4; ///< Amount of question types.
/** Types of goal destinations */
enum GoalType {

@ -53,7 +53,7 @@ void ShowTownDirectory();
void ShowIndustryDirectory();
void ShowSubsidiesList();
void ShowGoalsList();
void ShowGoalQuestion(uint16 id, uint32 button_mask, const char *question);
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question);
void ShowEstimatedCostOrIncome(Money cost, int x, int y);

@ -3015,7 +3015,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Зада
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Пстрыкніце па задачы, каб паказаць прадпрыемства/горад/клетку. Ctrl+пстрычка паказвае ў новым вакне.
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Пытаньне
STR_GOAL_QUESTION_CAPTION_QUESTION :Пытаньне
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Адмова

@ -2563,7 +2563,7 @@ STR_GOALS_NONE :{ORANGE}- Ни
STR_GOALS_COMPANY_TITLE :{BLACK}Цели на компанията:
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Въпрос
STR_GOAL_QUESTION_CAPTION_QUESTION :Въпрос
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Недобре

@ -2672,7 +2672,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Objectiu
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Clica sobre l'objectiu per centrar la vista principal sobre la indústria/poble/cel·la. Ctrl+clic per obrir una nova vista sobre la indústria/poble/cel·la
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Pregunta
STR_GOAL_QUESTION_CAPTION_QUESTION :Pregunta
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Cancel·la

@ -2767,7 +2767,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Ciljevi
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikni na cilj za centriranje središnjeg pogleda na industriju/grad/pločicu. Ctrl+Klik otvara novi prozor s pogledom na lokaciju industrije/grada/pločice
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Pitanje
STR_GOAL_QUESTION_CAPTION_QUESTION :Pitanje
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Poništi

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Bedrijfs
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klik op doel om venster te centreren op industrie/stad/tegel. Ctrl+Klik opent een nieuw venster op industrie/stad/tegel locatie
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Vraag
STR_GOAL_QUESTION_CAPTION_QUESTION :Vraag
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Annuleren

@ -2678,7 +2678,10 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Company
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on goal to centre main view on industry/town/tile. Ctrl+Click opens a new viewport on industry/town/tile location
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Question
STR_GOAL_QUESTION_CAPTION_QUESTION :Question
STR_GOAL_QUESTION_CAPTION_INFORMATION :Information
STR_GOAL_QUESTION_CAPTION_WARNING :Warning
STR_GOAL_QUESTION_CAPTION_ERROR :Error
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Cancel

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Company
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on goal to centre main view on industry/town/tile. Ctrl+Click opens a new viewport on industry/town/tile location
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Question
STR_GOAL_QUESTION_CAPTION_QUESTION :Question
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Cancel

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Company
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on goal to center main view on industry/town/tile. Ctrl+Click opens a new viewport on industry/town/tile location
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Question
STR_GOAL_QUESTION_CAPTION_QUESTION :Question
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Cancel

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Yhtiön
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikkaa tavoitetta keskittääksesi päänäkymän teollisuuteen/kaupunkiin/ruutuun. Ctrl+Klik avaa uuden näkymän teollisuuden/kaupungin/ruudun sijaintiin
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Kysymys
STR_GOAL_QUESTION_CAPTION_QUESTION :Kysymys
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Peruuta

@ -2679,7 +2679,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Objectif
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Cliquer sur l'objectif pour centrer la vue principale sur l'industrie, la ville ou la case. Ctrl-clic pour ouvrir une nouvelle vue sur l'industrie, la ville ou la case
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Question
STR_GOAL_QUESTION_CAPTION_QUESTION :Question
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Annuler

@ -2679,7 +2679,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Firmensp
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klick auf Ziel zentriert Hauptansicht auf Industrie/Stadt/Feld. Strg+Klick öffnet eine darauf zentrierte Zusatzansicht
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Frage
STR_GOAL_QUESTION_CAPTION_QUESTION :Frage
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Abbruch

@ -2735,7 +2735,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Cég cé
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Kattintással a fő nézetet a célra állítja. Ctrl+Kattintással új látképet nyit a gazdasági épület/település/mező helyéről
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Kérdés
STR_GOAL_QUESTION_CAPTION_QUESTION :Kérdés
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Mégse

@ -2706,7 +2706,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Obiettiv
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Fare clic su un obiettivo per centrare la visuale principale sull'industria, città o riquadro. CTRL+clic mostra l'industria/città/riquadro in una mini visuale
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Domanda
STR_GOAL_QUESTION_CAPTION_QUESTION :Domanda
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Annulla

@ -2671,7 +2671,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Uzņēmu
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikšķiniet uz mērķa, lai centrētu galveno skatu uz ražotni/pilsētu/flīzi. Ctrl+klikšķis atver jaunu skatu logu uz ražotnes/pilsētas/flīzes vietu.
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Jautājums
STR_GOAL_QUESTION_CAPTION_QUESTION :Jautājums
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Atcelt

@ -2740,7 +2740,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Kompanij
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Paspaudus ant nurodymo bus rodoma gamykla/miestas/vieta. Paspaudus laikant VALD (CTRL) klavišą bus atidarytas naujas langas su gamykla/miestu/vieta
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Klausimas
STR_GOAL_QUESTION_CAPTION_QUESTION :Klausimas
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Atšaukti

@ -2680,7 +2680,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Firmaets
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}klikk på mål for å gå til industri/by/rute . Ctrl+klikk åpner et nytt tilleggsvindu over industriens/byens/rutens beliggenhet
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Spørsmål
STR_GOAL_QUESTION_CAPTION_QUESTION :Spørsmål
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Avbryt

@ -2665,7 +2665,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Målet
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikk på mål for å gå til industri/by/rute. Ctrl+klikk åpner eit nytt tilleggsvindauge over industrien/byen/ruta sin lokasjon.
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Spørsmål
STR_GOAL_QUESTION_CAPTION_QUESTION :Spørsmål
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Avbryt

@ -3058,7 +3058,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Cele fir
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Kliknij na celu by wyśrodkować widok na przedsiębiorstwie/mieście/tytule. Ctrl+kliknięcie otwiera nowe okno podglądu lokacji danego przedsiębiorstwa.miasta/tytułu
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Pytanie
STR_GOAL_QUESTION_CAPTION_QUESTION :Pytanie
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Anuluj

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Ţintele
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click pe ţintă pentru a centra ecranul principal pe industrie/oraş/zonă. Ctrl+Click deschide o fereastră nouă de vizualizare a industriei/oraşului/zonei
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Întrebare
STR_GOAL_QUESTION_CAPTION_QUESTION :Întrebare
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Anulează

@ -2862,7 +2862,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Зада
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Щёлкните по задаче, чтобы показать предприятие/город/клетку. Ctrl+щелчок показывает в новом окне.
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Вопрос
STR_GOAL_QUESTION_CAPTION_QUESTION :Вопрос
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Отменить

@ -2873,7 +2873,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Ciljevi
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikom na cilj premešta se glavni pogled na fabriku/naselje/pločicu. Ctrl+Kilk otvara novi pogled na lokaciju fabrike/naselja/pločice
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Pitanje
STR_GOAL_QUESTION_CAPTION_QUESTION :Pitanje
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Otkaži

@ -2657,7 +2657,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}公司
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}点击使得视图移动到该工业/城镇/地块. Ctrl+左键 在该处创建一个视点.
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}帮助索引
STR_GOAL_QUESTION_CAPTION_QUESTION :帮助索引
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :取消

@ -2831,7 +2831,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Cilji po
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Klikni na cilj za pogled na industrijo/mesto/ploščo. Ctrl+Klik odpre novo okno na industrijo/mesto/ploščo
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Vprašanje
STR_GOAL_QUESTION_CAPTION_QUESTION :Vprašanje
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Prekliči

@ -2679,7 +2679,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Metas de
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click en una meta para centrar la vista principal en la casilla, industria o pueblo. Ctrl+Click abre una nueva vista en esa localización
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Pregunta
STR_GOAL_QUESTION_CAPTION_QUESTION :Pregunta
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Cancelar

@ -2666,7 +2666,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Şirket
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Ana görünümü istenen fabrika/kasaba/kareye getirmek için hedefe tıklayın. Ctrl+Tıklama fabrika/kasaba/kare konumunda yeni bir pencerede görünüm açar
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Soru
STR_GOAL_QUESTION_CAPTION_QUESTION :Soru
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :İptal

@ -2794,7 +2794,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Цілі
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Клік мишкою на цілі (меті) відобразить по центру промисловість/місто/клітинку у головному вікні. Ctrl+клік відкриє міні-вікно
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Питання
STR_GOAL_QUESTION_CAPTION_QUESTION :Питання
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Відмінити

@ -2670,7 +2670,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}اهدا
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}روی هدف کلیک کنید تا نمای اصلی را به مرکز صنایع/شهر/قطعه ببرد. Ctrl+Click یک نمای جدید از محل صنایع/شهر قطعه باز می کند
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}سوال
STR_GOAL_QUESTION_CAPTION_QUESTION :سوال
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :لغو

@ -2678,7 +2678,7 @@ STR_GOALS_COMPANY_TITLE :{BLACK}Nodau cw
STR_GOALS_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Cliciwch ar nod i ganoli'r brif olygfa ar y diwydiant/tref/teil Mae Ctrl+Clic yn agor ffenestr golwg newydd ar leoliad y diwydiant/tref/teil
# Goal question window
STR_GOAL_QUESTION_CAPTION :{WHITE}Cwestiwn
STR_GOAL_QUESTION_CAPTION_QUESTION :Cwestiwn
### Start of Goal Question button list
STR_GOAL_QUESTION_BUTTON_CANCEL :Canslo

@ -27,6 +27,10 @@ void SQGSGoal_Register(Squirrel *engine)
SQGSGoal.DefSQConst(engine, ScriptGoal::GT_INDUSTRY, "GT_INDUSTRY");
SQGSGoal.DefSQConst(engine, ScriptGoal::GT_TOWN, "GT_TOWN");
SQGSGoal.DefSQConst(engine, ScriptGoal::GT_COMPANY, "GT_COMPANY");
SQGSGoal.DefSQConst(engine, ScriptGoal::QT_QUESTION, "QT_QUESTION");
SQGSGoal.DefSQConst(engine, ScriptGoal::QT_INFORMATION, "QT_INFORMATION");
SQGSGoal.DefSQConst(engine, ScriptGoal::QT_WARNING, "QT_WARNING");
SQGSGoal.DefSQConst(engine, ScriptGoal::QT_ERROR, "QT_ERROR");
SQGSGoal.DefSQConst(engine, ScriptGoal::BUTTON_CANCEL, "BUTTON_CANCEL");
SQGSGoal.DefSQConst(engine, ScriptGoal::BUTTON_OK, "BUTTON_OK");
SQGSGoal.DefSQConst(engine, ScriptGoal::BUTTON_NO, "BUTTON_NO");
@ -49,7 +53,7 @@ void SQGSGoal_Register(Squirrel *engine)
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::IsValidGoal, "IsValidGoal", 2, ".i");
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::New, "New", 5, ".i.ii");
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::Remove, "Remove", 2, ".i");
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::Question, "Question", 5, ".ii.i");
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::Question, "Question", 6, ".ii.ii");
SQGSGoal.DefSQStaticMethod(engine, &ScriptGoal::CloseQuestion, "CloseQuestion", 2, ".i");
SQGSGoal.PostRegister(engine);

@ -51,7 +51,7 @@
return ScriptObject::DoCommand(0, goal_id, 0, CMD_REMOVE_GOAL);
}
/* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, int buttons)
/* static */ bool ScriptGoal::Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons)
{
CCountedPtr<Text> counter(question);
@ -60,11 +60,13 @@
EnforcePrecondition(false, !StrEmpty(question->GetEncodedText()));
EnforcePrecondition(false, company == ScriptCompany::COMPANY_INVALID || ScriptCompany::ResolveCompanyID(company) != ScriptCompany::COMPANY_INVALID);
EnforcePrecondition(false, CountBits(buttons) >= 1 && CountBits(buttons) <= 3);
EnforcePrecondition(false, buttons < (1 << ::GOAL_QUESTION_BUTTON_COUNT));
EnforcePrecondition(false, type < ::GOAL_QUESTION_TYPE_COUNT);
uint8 c = company;
if (company == ScriptCompany::COMPANY_INVALID) c = INVALID_COMPANY;
return ScriptObject::DoCommand(0, uniqueid | (c << 16), buttons, CMD_GOAL_QUESTION, question->GetEncodedText());
return ScriptObject::DoCommand(0, uniqueid | (c << 16) | (type << 24), buttons, CMD_GOAL_QUESTION, question->GetEncodedText());
}
/* static */ bool ScriptGoal::CloseQuestion(uint16 uniqueid)

@ -41,6 +41,17 @@ public:
GT_COMPANY = ::GT_COMPANY, ///< Destination is a company.
};
/**
* Types of queries we could do to the user.
* Basically the title of the question window.
*/
enum QuestionType {
QT_QUESTION, ///< Asking a simple question; title: Question.
QT_INFORMATION, ///< Showing an informational message; title: Information.
QT_WARNING, ///< Showing a warning; title: Warning.
QT_ERROR, ///< Showing an error; title: Error.
};
enum QuestionButton {
/* Note: these values represent part of the string list starting with STR_GOAL_QUESTION_BUTTON_CANCEL */
BUTTON_CANCEL = (1 << 0), ///< Cancel button.
@ -97,6 +108,7 @@ public:
* @param uniqueid Your unique id to distinguish results of multiple questions in the returning event.
* @param company The company to ask the question, or ScriptCompany::COMPANY_INVALID for all.
* @param question The question to ask (can be either a raw string, or a ScriptText object).
* @param type The type of question that is being asked.
* @param buttons Any combinations (at least 1, up to 3) of buttons defined in QuestionButton. Like BUTTON_YES + BUTTON_NO.
* @return True if the action succeeded.
* @pre No ScriptCompanyMode may be in scope.
@ -106,7 +118,7 @@ public:
* @note Replies to the question are given by you via the event ScriptEvent_GoalQuestionAnswer.
* @note There is no guarantee you ever get a reply on your question.
*/
static bool Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, int buttons);
static bool Question(uint16 uniqueid, ScriptCompany::CompanyID company, Text *question, QuestionType type, int buttons);
/**
* Close the question on all clients.

@ -17,6 +17,8 @@ namespace SQConvert {
template <> inline int Return<ScriptGoal::GoalID>(HSQUIRRELVM vm, ScriptGoal::GoalID res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptGoal::GoalType GetParam(ForceType<ScriptGoal::GoalType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptGoal::GoalType)tmp; }
template <> inline int Return<ScriptGoal::GoalType>(HSQUIRRELVM vm, ScriptGoal::GoalType res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptGoal::QuestionType GetParam(ForceType<ScriptGoal::QuestionType>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptGoal::QuestionType)tmp; }
template <> inline int Return<ScriptGoal::QuestionType>(HSQUIRRELVM vm, ScriptGoal::QuestionType res) { sq_pushinteger(vm, (int32)res); return 1; }
template <> inline ScriptGoal::QuestionButton GetParam(ForceType<ScriptGoal::QuestionButton>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger(vm, index, &tmp); return (ScriptGoal::QuestionButton)tmp; }
template <> inline int Return<ScriptGoal::QuestionButton>(HSQUIRRELVM vm, ScriptGoal::QuestionButton res) { sq_pushinteger(vm, (int32)res); return 1; }

@ -21,6 +21,7 @@ enum GoalListWidgets {
/** Widgets of the #GoalQuestionWindow class. */
enum GoalQuestionWidgets {
WID_GQ_CAPTION, ///< Caption of the window.
WID_GQ_QUESTION, ///< Question text.
WID_GQ_BUTTONS, ///< Buttons selection (between 1, 2 or 3).
WID_GQ_BUTTON_1, ///< First button.

Loading…
Cancel
Save