Changeset - r28463:8a2d650ec60e
[Not reviewed]
master
0 3 0
Loïc Guilloux - 4 months ago 2024-01-15 20:41:44
glx22@users.noreply.github.com
Change: Redesign script debug window (#11782)
3 files changed with 15 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/script/script_gui.cpp
Show inline comments
 
@@ -1233,7 +1233,7 @@ struct ScriptDebugWindow : public Window
 
/** Make a number of rows with buttons for each company for the Script debug window. */
 
std::unique_ptr<NWidgetBase> MakeCompanyButtonRowsScriptDebug()
 
{
 
	return MakeCompanyButtonRows(WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 8, STR_AI_DEBUG_SELECT_AI_TOOLTIP);
 
	return MakeCompanyButtonRows(WID_SCRD_COMPANY_BUTTON_START, WID_SCRD_COMPANY_BUTTON_END, COLOUR_GREY, 5, STR_AI_DEBUG_SELECT_AI_TOOLTIP, false);
 
}
 

	
 
/** Widgets for the Script debug window. */
 
@@ -1245,14 +1245,16 @@ static const NWidgetPart _nested_script_
 
		NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
 
		NWidget(WWT_STICKYBOX, COLOUR_GREY),
 
	EndContainer(),
 
	NWidget(WWT_PANEL, COLOUR_GREY, WID_SCRD_VIEW),
 
		NWidgetFunction(MakeCompanyButtonRowsScriptDebug), SetPadding(0, 2, 1, 2),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SCRD_SCRIPT_GAME), SetMinimalSize(100, 20), SetResize(1, 0), SetDataTip(STR_AI_GAME_SCRIPT, STR_AI_GAME_SCRIPT_TOOLTIP),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SCRD_NAME_TEXT), SetFill(1, 0), SetResize(1, 0), SetDataTip(STR_JUST_STRING2, STR_AI_DEBUG_NAME_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCRD_SETTINGS), SetMinimalSize(100, 20), SetDataTip(STR_AI_DEBUG_SETTINGS, STR_AI_DEBUG_SETTINGS_TOOLTIP),
 
		NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCRD_RELOAD_TOGGLE), SetMinimalSize(100, 20), SetDataTip(STR_AI_DEBUG_RELOAD, STR_AI_DEBUG_RELOAD_TOOLTIP),
 
		NWidget(WWT_PANEL, COLOUR_GREY, WID_SCRD_VIEW),
 
			NWidgetFunction(MakeCompanyButtonRowsScriptDebug), SetPadding(0, 2, 1, 2),
 
		EndContainer(),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SCRD_SCRIPT_GAME), SetMinimalSize(100, 20), SetDataTip(STR_AI_GAME_SCRIPT, STR_AI_GAME_SCRIPT_TOOLTIP),
 
		NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_SCRD_NAME_TEXT), SetResize(1, 0), SetDataTip(STR_JUST_STRING2, STR_AI_DEBUG_NAME_TOOLTIP),
 
		NWidget(NWID_VERTICAL),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCRD_SETTINGS), SetMinimalSize(100, 20), SetFill(0, 1), SetDataTip(STR_AI_DEBUG_SETTINGS, STR_AI_DEBUG_SETTINGS_TOOLTIP),
 
			NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_SCRD_RELOAD_TOGGLE), SetMinimalSize(100, 20), SetFill(0, 1), SetDataTip(STR_AI_DEBUG_RELOAD, STR_AI_DEBUG_RELOAD_TOOLTIP),
 
		EndContainer(),
 
	EndContainer(),
 
	NWidget(NWID_HORIZONTAL),
 
		NWidget(NWID_VERTICAL),
src/widget.cpp
Show inline comments
 
@@ -3329,9 +3329,10 @@ std::unique_ptr<NWidgetBase> MakeWindowN
 
 * @param colour The colour in which to draw the button.
 
 * @param max_length Maximal number of company buttons in one row.
 
 * @param button_tooltip The tooltip-string of every button.
 
 * @param resizable Whether the rows are resizable.
 
 * @return Panel with rows of company buttons.
 
 */
 
std::unique_ptr<NWidgetBase> MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip)
 
std::unique_ptr<NWidgetBase> MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip, bool resizable)
 
{
 
	assert(max_length >= 1);
 
	std::unique_ptr<NWidgetVertical> vert = nullptr; // Storage for all rows.
 
@@ -3358,7 +3359,7 @@ std::unique_ptr<NWidgetBase> MakeCompany
 
		auto panel = std::make_unique<NWidgetBackground>(WWT_PANEL, button_colour, widnum);
 
		panel->SetMinimalSize(sprite_size.width, sprite_size.height);
 
		panel->SetFill(1, 1);
 
		panel->SetResize(1, 0);
 
		if (resizable) panel->SetResize(1, 0);
 
		panel->SetDataTip(0x0, button_tooltip);
 
		hor->Add(std::move(panel));
 
		hor_length++;
 
@@ -3369,7 +3370,7 @@ std::unique_ptr<NWidgetBase> MakeCompany
 
		/* Last row is partial, add a spacer at the end to force all buttons to the left. */
 
		auto spc = std::make_unique<NWidgetSpacer>(sprite_size.width, sprite_size.height);
 
		spc->SetFill(1, 1);
 
		spc->SetResize(1, 0);
 
		if (resizable) spc->SetResize(1, 0);
 
		hor->Add(std::move(spc));
 
	}
 
	if (hor != nullptr) vert->Add(std::move(hor));
src/widget_type.h
Show inline comments
 
@@ -1356,7 +1356,7 @@ bool IsContainerWidgetType(WidgetType tp
 
std::unique_ptr<NWidgetBase> MakeNWidgets(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, std::unique_ptr<NWidgetBase> &&container);
 
std::unique_ptr<NWidgetBase> MakeWindowNWidgetTree(const NWidgetPart *nwid_begin, const NWidgetPart *nwid_end, NWidgetStacked **shade_select);
 

	
 
std::unique_ptr<NWidgetBase> MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip);
 
std::unique_ptr<NWidgetBase> MakeCompanyButtonRows(WidgetID widget_first, WidgetID widget_last, Colours button_colour, int max_length, StringID button_tooltip, bool resizable = true);
 

	
 
void SetupWidgetDimensions();
 

	
0 comments (0 inline, 0 general)