Changeset - r21932:5451a642d3e3
[Not reviewed]
master
0 2 0
alberth - 9 years ago 2014-12-18 18:22:23
alberth@openttd.org
(svn r27086) -Codechange: Simplify opening of windows by always returning a valid window pointer.
2 files changed with 9 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -693,26 +693,26 @@ static WindowDesc _newgrf_inspect_desc(
 
 * The index is normally an in-game location/identifier, such
 
 * as a TileIndex or an IndustryID depending on the feature
 
 * we want to inspect.
 
 * @param feature The feature we want to inspect.
 
 * @param index   The index/identifier of the feature to inspect.
 
 * @param grfid   GRFID of the item opening this window, or 0 if not opened by other window.
 
 */
 
void ShowNewGRFInspectWindow(GrfSpecFeature feature, uint index, const uint32 grfid)
 
{
 
	if (!IsNewGRFInspectable(feature, index)) return;
 

	
 
	WindowNumber wno = GetInspectWindowNumber(feature, index);
 
	NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(feature == GSF_TRAINS || feature == GSF_ROADVEHICLES ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc, wno);
 
	if (w == NULL) w = (NewGRFInspectWindow *)FindWindowById(WC_NEWGRF_INSPECT, wno);
 
	WindowDesc *desc = (feature == GSF_TRAINS || feature == GSF_ROADVEHICLES) ? &_newgrf_inspect_chain_desc : &_newgrf_inspect_desc;
 
	NewGRFInspectWindow *w = AllocateWindowDescFront<NewGRFInspectWindow>(desc, wno, true);
 
	w->SetCallerGRFID(grfid);
 
}
 

	
 
/**
 
 * Invalidate the inspect window for a given feature and index.
 
 * The index is normally an in-game location/identifier, such
 
 * as a TileIndex or an IndustryID depending on the feature
 
 * we want to inspect.
 
 * @param feature The feature we want to invalidate the window for.
 
 * @param index   The index/identifier of the feature to invalidate.
 
 */
 
void InvalidateNewGRFInspectWindow(GrfSpecFeature feature, uint index)
src/story_gui.cpp
Show inline comments
 
@@ -749,22 +749,24 @@ static const NWidgetPart _nested_story_b
 
			NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
 
		EndContainer(),
 
	EndContainer(),
 
};
 

	
 
static WindowDesc _story_book_desc(
 
	WDP_CENTER, "view_story", 400, 300,
 
	WC_STORY_BOOK, WC_NONE,
 
	0,
 
	_nested_story_book_widgets, lengthof(_nested_story_book_widgets)
 
);
 

	
 
/**
 
 * 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.
 
 */
 
void ShowStoryBook(CompanyID company, uint16 page_id)
 
{
 
	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, company);
 
		w->SetSelectedPage(page_id);
 
	}
 
	StoryBookWindow *w = AllocateWindowDescFront<StoryBookWindow>(&_story_book_desc, company, true);
 
	if (page_id != INVALID_STORY_PAGE) w->SetSelectedPage(page_id);
 
}
0 comments (0 inline, 0 general)