Changeset - r28651:c00401794427
[Not reviewed]
master
0 3 0
Patric Stout - 10 months ago 2024-02-03 07:09:55
truebrain@openttd.org
Change: only open story-book in center when a GS does it (#11916)
3 files changed with 13 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/gui.h
Show inline comments
 
@@ -65,7 +65,7 @@ void ShowGoalsList(CompanyID company);
 
void ShowGoalQuestion(uint16_t id, byte type, uint32_t button_mask, const std::string &question);
 

	
 
/* story_gui.cpp */
 
void ShowStoryBook(CompanyID company, uint16_t page_id = INVALID_STORY_PAGE);
 
void ShowStoryBook(CompanyID company, uint16_t page_id = INVALID_STORY_PAGE, bool centered = false);
 

	
 
/* viewport_gui.cpp */
 
void ShowExtraViewportWindow(TileIndex tile = INVALID_TILE);
src/story.cpp
Show inline comments
 
@@ -368,7 +368,7 @@ CommandCost CmdShowStoryPage(DoCommandFl
 

	
 
	if (flags & DC_EXEC) {
 
		StoryPage *g = StoryPage::Get(page_id);
 
		if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(_local_company, page_id);
 
		if ((g->company != INVALID_COMPANY && g->company == _local_company) || (g->company == INVALID_COMPANY && Company::IsValidID(_local_company))) ShowStoryBook(_local_company, page_id, true);
 
	}
 

	
 
	return CommandCost();
src/story_gui.cpp
Show inline comments
 
@@ -969,7 +969,14 @@ static constexpr NWidgetPart _nested_sto
 
};
 

	
 
static WindowDesc _story_book_desc(__FILE__, __LINE__,
 
	WDP_CENTER, "view_story", 400, 300,
 
	WDP_AUTO, "view_story", 400, 300,
 
	WC_STORY_BOOK, WC_NONE,
 
	0,
 
	std::begin(_nested_story_book_widgets), std::end(_nested_story_book_widgets)
 
);
 

	
 
static WindowDesc _story_book_gs_desc(__FILE__, __LINE__,
 
	WDP_CENTER, "view_story_gs", 400, 300,
 
	WC_STORY_BOOK, WC_NONE,
 
	0,
 
	std::begin(_nested_story_book_widgets), std::end(_nested_story_book_widgets)
 
@@ -1041,11 +1048,12 @@ static CursorID TranslateStoryPageButton
 
 * Raise or create the story book window for \a company, at page \a page_id.
 
 * @param company 'Owner' of the story book, may be #INVALID_COMPANY.
 
 * @param page_id Page to open, may be #INVALID_STORY_PAGE.
 
 * @param centered Whether to open the window centered.
 
 */
 
void ShowStoryBook(CompanyID company, uint16_t page_id)
 
void ShowStoryBook(CompanyID company, uint16_t page_id, bool centered)
 
{
 
	if (!Company::IsValidID(company)) company = (CompanyID)INVALID_COMPANY;
 

	
 
	StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, company, true);
 
	StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(centered ? &_story_book_gs_desc : &_story_book_desc, company, true);
 
	if (page_id != INVALID_STORY_PAGE) w->SetSelectedPage(page_id);
 
}
0 comments (0 inline, 0 general)