summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2013-06-09 13:13:47 +0000
committerzuu <zuu@openttd.org>2013-06-09 13:13:47 +0000
commit8980cb427dd4f385e050f1e9075b345d798ae25c (patch)
treec93bd138cc0696792f6830878d085ced932a5288
parentf373d29d62500ba0d33a707c9b0e03f97465b554 (diff)
downloadopenttd-8980cb427dd4f385e050f1e9075b345d798ae25c.tar.xz
(svn r25369) -Add: allow opening a story window specific to a company
-rw-r--r--src/gui.h3
-rw-r--r--src/lang/english.txt3
-rw-r--r--src/story.cpp2
-rw-r--r--src/story_gui.cpp32
-rw-r--r--src/toolbar_gui.cpp2
5 files changed, 29 insertions, 13 deletions
diff --git a/src/gui.h b/src/gui.h
index fe14e2d6e..6ef8261a0 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -17,6 +17,7 @@
#include "tile_type.h"
#include "transport_type.h"
#include "story_type.h"
+#include "company_type.h"
struct Window;
@@ -52,7 +53,7 @@ void ShowIndustryCargoesWindow();
void ShowSubsidiesList();
void ShowGoalsList();
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question);
-void ShowStoryBook(uint16 page_id = INVALID_STORY_PAGE);
+void ShowStoryBook(CompanyID company, uint16 page_id = INVALID_STORY_PAGE);
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 77f567253..561da1461 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -2975,7 +2975,8 @@ STR_SUBSIDIES_SUBSIDISED_FROM_TO :{ORANGE}{STRING
STR_SUBSIDIES_TOOLTIP_CLICK_ON_SERVICE_TO_CENTER :{BLACK}Click on service to centre main view on industry/town. Ctrl+Click opens a new viewport on industry/town location
# Story book window
-STR_STORY_BOOK_CAPTION :{WHITE}Story Book
+STR_STORY_BOOK_CAPTION :{WHITE}{COMPANY} Story Book
+STR_STORY_BOOK_SPECTATOR_CAPTION :{WHITE}Global Story Book
STR_STORY_BOOK_TITLE :{YELLOW}{RAW_STRING}
STR_STORY_BOOK_GENERIC_PAGE_ITEM :Page {NUM}
STR_STORY_BOOK_SEL_PAGE_TOOLTIP :{BLACK}Jump to a specific page by selecting it in this drop down list.
diff --git a/src/story.cpp b/src/story.cpp
index 74cdd1d5c..4e0492376 100644
--- a/src/story.cpp
+++ b/src/story.cpp
@@ -264,7 +264,7 @@ CommandCost CmdShowStoryPage(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (flags & DC_EXEC) {
StoryPage *g = StoryPage::Get(p1);
- if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(p1);
+ if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(_local_company, p1);
}
return CommandCost();
diff --git a/src/story_gui.cpp b/src/story_gui.cpp
index 64782b90e..5c9b0c9ed 100644
--- a/src/story_gui.cpp
+++ b/src/story_gui.cpp
@@ -24,6 +24,7 @@
#include "goal_base.h"
#include "viewport_func.h"
#include "window_func.h"
+#include "company_base.h"
#include "widgets/story_widget.h"
@@ -107,7 +108,7 @@ protected:
*/
bool IsPageAvailable(const StoryPage *page) const
{
- return page->company == INVALID_COMPANY || page->company == _local_company;
+ return page->company == INVALID_COMPANY || page->company == this->window_number;
}
/**
@@ -460,10 +461,21 @@ public:
virtual void SetStringParameters(int widget) const
{
- if (widget != WID_SB_SEL_PAGE) return;
-
- StoryPage *page = this->GetSelPage();
- SetDParamStr(0, page != NULL && page->title != NULL ? page->title : this->selected_generic_title);
+ switch (widget) {
+ case WID_SB_SEL_PAGE: {
+ StoryPage *page = this->GetSelPage();
+ SetDParamStr(0, page != NULL && page->title != NULL ? page->title : this->selected_generic_title);
+ break;
+ }
+ case WID_SB_CAPTION:
+ if (this->window_number == INVALID_COMPANY) {
+ SetDParam(0, STR_STORY_BOOK_SPECTATOR_CAPTION);
+ } else {
+ SetDParam(0, STR_STORY_BOOK_CAPTION);
+ SetDParam(1, this->window_number);
+ }
+ break;
+ }
}
virtual void DrawWidget(const Rect &r, int widget) const
@@ -697,7 +709,7 @@ GUIStoryPageElementList::SortFunction * const StoryBookWindow::page_element_sort
static const NWidgetPart _nested_story_book_widgets[] = {
NWidget(NWID_HORIZONTAL),
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
- NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SB_CAPTION), SetDataTip(STR_STORY_BOOK_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
+ NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SB_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
@@ -726,11 +738,13 @@ static WindowDesc _story_book_desc(
_nested_story_book_widgets, lengthof(_nested_story_book_widgets)
);
-void ShowStoryBook(uint16 page_id)
+void ShowStoryBook(CompanyID company, uint16 page_id)
{
- StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, 0);
+ if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY;
+
+ StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, company);
if (page_id != INVALID_STORY_PAGE) {
- if (w == NULL) w = (StoryBookWindow *)FindWindowById(WC_STORY_BOOK, 0);
+ if (w == NULL) w = (StoryBookWindow *)FindWindowById(WC_STORY_BOOK, company);
w->SetSelectedPage(page_id);
}
}
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index cab5593eb..d5e7d7f4e 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -656,7 +656,7 @@ static CallBackFunction MenuClickLeague(int index)
{
switch (index) {
case 0: ShowGoalsList(); break;
- case 1: ShowStoryBook(); break;
+ case 1: ShowStoryBook(_local_company); break;
case 2: ShowCompanyLeagueTable(); break;
case 3: ShowPerformanceRatingDetail(); break;
case 4: ShowHighscoreTable(); break;