Skip to content

Instantly share code, notes, and snippets.

@Wolfolo Wolfolo/uitest.patch Secret
Created Aug 12, 2017

Embed
What would you like to do?
diff --git a/src/gui.h b/src/gui.h
index 39f1ea6..273f739 100644
--- a/src/gui.h
+++ b/src/gui.h
@@ -54,6 +54,7 @@ void ShowSubsidiesList();
void ShowGoalsList(CompanyID company);
void ShowGoalQuestion(uint16 id, byte type, uint32 button_mask, const char *question);
void ShowStoryBook(CompanyID company, uint16 page_id = INVALID_STORY_PAGE);
+void ShowUITestWindow();
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 5d79448..df0d7c4 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -479,6 +479,7 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :About 'OpenTTD'
STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite aligner
STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Toggle bounding boxes
STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Toggle colouring of dirty blocks
+STR_ABOUT_MENU_UI_TEST :UI Test window
############ range ends here
############ range for ordinal numbers used for the place in the highscore window
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index 2d3871f..feade37 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -1216,3 +1216,31 @@ void ShowQuery(StringID caption, StringID message, Window *parent, QueryCallback
new QueryWindow(&_query_desc, caption, message, parent, callback);
}
+
+static const NWidgetPart _nested_ui_test_widgets[] = {
+ NWidget(NWID_HORIZONTAL),
+ NWidget(WWT_CLOSEBOX, COLOUR_GREY),
+ NWidget(WWT_CAPTION, COLOUR_GREY, WID_UT_CAPTION), SetDataTip(STR_WHITE_STRING, STR_NULL),
+ EndContainer(),
+ NWidget(WWT_PANEL, COLOUR_RED), SetMinimalSize(200, 100),
+ EndContainer(),
+};
+
+static WindowDesc _ui_test_desc(
+ WDP_CENTER, "ui_test", 0, 0,
+ WC_UI_TEST, WC_NONE,
+ 0,
+ _nested_ui_test_widgets, lengthof(_nested_ui_test_widgets)
+);
+
+struct UITestWindow : public Window {
+ UITestWindow() : Window(&_ui_test_desc) {
+ this->InitNested(WN_UI_TEST);
+ }
+};
+
+void ShowUITestWindow()
+{
+ DeleteWindowByClass(WC_UI_TEST);
+ new UITestWindow();
+}
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index f253be8..4d9bd6d 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1045,7 +1045,7 @@ static CallBackFunction PlaceLandBlockInfo()
static CallBackFunction ToolbarHelpClick(Window *w)
{
- PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 12 : 9);
+ PopupMainToolbMenu(w, WID_TN_HELP, STR_ABOUT_MENU_LAND_BLOCK_INFO, _settings_client.gui.newgrf_developer_tools ? 13 : 9);
return CBF_NONE;
}
@@ -1151,6 +1151,7 @@ static CallBackFunction MenuClickHelp(int index)
case 9: ShowSpriteAlignerWindow(); break;
case 10: ToggleBoundingBoxes(); break;
case 11: ToggleDirtyBlocks(); break;
+ case 12: ShowUITestWindow(); break;
}
return CBF_NONE;
}
diff --git a/src/widgets/misc_widget.h b/src/widgets/misc_widget.h
index a6dd081..99cf097 100644
--- a/src/widgets/misc_widget.h
+++ b/src/widgets/misc_widget.h
@@ -54,4 +54,9 @@ enum TextfileWidgets {
WID_TF_HSCROLLBAR, ///< Horizontal scrollbar to scroll through the textfile left-to-right.
};
+/** Widgets of the #UITestWindow class */
+enum UITestWidgets {
+ WID_UT_CAPTION,
+};
+
#endif /* WIDGETS_MISC_WIDGET_H */
diff --git a/src/window_type.h b/src/window_type.h
index 809e81d..ec83bba 100644
--- a/src/window_type.h
+++ b/src/window_type.h
@@ -33,6 +33,8 @@ enum WindowNumberEnum {
WN_NETWORK_STATUS_WINDOW_JOIN = 0, ///< Network join status.
WN_NETWORK_STATUS_WINDOW_CONTENT_DOWNLOAD, ///< Network content download status.
+
+ WN_UI_TEST = 0,
};
/** %Window classes. */
@@ -681,6 +683,8 @@ enum WindowClass {
*/
WC_SAVE_PRESET,
+ WC_UI_TEST,
+
WC_INVALID = 0xFFFF, ///< Invalid window.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.