Merge branch 'enhanced_viewport_overlay' into jgrpp
# Conflicts: # src/misc_gui.cpp
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include "newgrf_debug.h"
|
#include "newgrf_debug.h"
|
||||||
#include "zoom_func.h"
|
#include "zoom_func.h"
|
||||||
#include "tunnelbridge_map.h"
|
#include "tunnelbridge_map.h"
|
||||||
|
#include "viewport_type.h"
|
||||||
|
|
||||||
#include "widgets/misc_widget.h"
|
#include "widgets/misc_widget.h"
|
||||||
|
|
||||||
@@ -661,6 +662,9 @@ struct TooltipsWindow : public Window
|
|||||||
uint64 params[5]; ///< The string parameters.
|
uint64 params[5]; ///< The string parameters.
|
||||||
TooltipCloseCondition close_cond; ///< Condition for closing the window.
|
TooltipCloseCondition close_cond; ///< Condition for closing the window.
|
||||||
char buffer[DRAW_STRING_BUFFER]; ///< Text to draw
|
char buffer[DRAW_STRING_BUFFER]; ///< Text to draw
|
||||||
|
int viewport_virtual_left; ///< Owner viewport state: left
|
||||||
|
int viewport_virtual_top; ///< Owner viewport state: top
|
||||||
|
bool delete_next_mouse_loop; ///< Delete window on the next mouse loop
|
||||||
|
|
||||||
TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc)
|
TooltipsWindow(Window *parent, StringID str, uint paramcount, const uint64 params[], TooltipCloseCondition close_tooltip) : Window(&_tool_tips_desc)
|
||||||
{
|
{
|
||||||
@@ -671,7 +675,12 @@ struct TooltipsWindow : public Window
|
|||||||
memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
|
memcpy(this->params, params, sizeof(this->params[0]) * paramcount);
|
||||||
this->paramcount = paramcount;
|
this->paramcount = paramcount;
|
||||||
this->close_cond = close_tooltip;
|
this->close_cond = close_tooltip;
|
||||||
|
this->delete_next_mouse_loop = false;
|
||||||
if (this->paramcount == 0) GetString(this->buffer, str, lastof(this->buffer)); // Get the text while params are available
|
if (this->paramcount == 0) GetString(this->buffer, str, lastof(this->buffer)); // Get the text while params are available
|
||||||
|
if (close_tooltip == TCC_HOVER_VIEWPORT) {
|
||||||
|
this->viewport_virtual_left = parent->viewport->virtual_left;
|
||||||
|
this->viewport_virtual_top = parent->viewport->virtual_top;
|
||||||
|
}
|
||||||
|
|
||||||
this->InitNested();
|
this->InitNested();
|
||||||
|
|
||||||
@@ -730,7 +739,7 @@ struct TooltipsWindow : public Window
|
|||||||
virtual void OnMouseLoop()
|
virtual void OnMouseLoop()
|
||||||
{
|
{
|
||||||
/* Always close tooltips when the cursor is not in our window. */
|
/* Always close tooltips when the cursor is not in our window. */
|
||||||
if (!_cursor.in_window) {
|
if (!_cursor.in_window || this->delete_next_mouse_loop) {
|
||||||
delete this;
|
delete this;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -741,6 +750,17 @@ struct TooltipsWindow : public Window
|
|||||||
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
|
case TCC_RIGHT_CLICK: if (!_right_button_down) delete this; break;
|
||||||
case TCC_LEFT_CLICK: if (!_left_button_down) delete this; break;
|
case TCC_LEFT_CLICK: if (!_left_button_down) delete this; break;
|
||||||
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
|
case TCC_HOVER: if (!_mouse_hovering) delete this; break;
|
||||||
|
|
||||||
|
case TCC_HOVER_VIEWPORT:
|
||||||
|
if (!_mouse_hovering) {
|
||||||
|
delete this;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (this->viewport_virtual_left != this->parent->viewport->virtual_left ||
|
||||||
|
this->viewport_virtual_top != this->parent->viewport->virtual_top) {
|
||||||
|
this->delete_next_mouse_loop = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -225,7 +225,7 @@ void ShowTooltipForTile(Window *w, const TileIndex tile)
|
|||||||
case MP_HOUSE: {
|
case MP_HOUSE: {
|
||||||
if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES)) return; // No need for a town name tooltip when it is already displayed
|
if (HasBit(_display_opt, DO_SHOW_TOWN_NAMES)) return; // No need for a town name tooltip when it is already displayed
|
||||||
SetDParam(0, GetTownIndex(tile));
|
SetDParam(0, GetTownIndex(tile));
|
||||||
GuiShowTooltips(w, STR_TOWN_NAME_TOOLTIP, 0, NULL, TCC_HOVER);
|
GuiShowTooltips(w, STR_TOWN_NAME_TOOLTIP, 0, NULL, TCC_HOVER_VIEWPORT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MP_INDUSTRY: {
|
case MP_INDUSTRY: {
|
||||||
@@ -243,7 +243,7 @@ void ShowTooltipForTile(Window *w, const TileIndex tile)
|
|||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GuiShowTooltips(w, str, 0, NULL, TCC_HOVER);
|
GuiShowTooltips(w, str, 0, NULL, TCC_HOVER_VIEWPORT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@@ -33,7 +33,7 @@ enum ViewportMapType {
|
|||||||
* Data structure for viewport, display of a part of the world
|
* Data structure for viewport, display of a part of the world
|
||||||
*/
|
*/
|
||||||
struct ViewPort {
|
struct ViewPort {
|
||||||
int left; ///< Screen coordinate left egde of the viewport
|
int left; ///< Screen coordinate left edge of the viewport
|
||||||
int top; ///< Screen coordinate top edge of the viewport
|
int top; ///< Screen coordinate top edge of the viewport
|
||||||
int width; ///< Screen width of the viewport
|
int width; ///< Screen width of the viewport
|
||||||
int height; ///< Screen height of the viewport
|
int height; ///< Screen height of the viewport
|
||||||
|
@@ -871,6 +871,7 @@ enum TooltipCloseCondition {
|
|||||||
TCC_RIGHT_CLICK,
|
TCC_RIGHT_CLICK,
|
||||||
TCC_LEFT_CLICK,
|
TCC_LEFT_CLICK,
|
||||||
TCC_HOVER,
|
TCC_HOVER,
|
||||||
|
TCC_HOVER_VIEWPORT,
|
||||||
};
|
};
|
||||||
|
|
||||||
void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
|
void GuiShowTooltips(Window *parent, StringID str, uint paramcount = 0, const uint64 params[] = NULL, TooltipCloseCondition close_tooltip = TCC_HOVER);
|
||||||
|
Reference in New Issue
Block a user