Changeset View
Changeset View
Standalone View
Standalone View
source/gui/CTooltip.cpp
Show All 13 Lines | |||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "CTooltip.h" | #include "CTooltip.h" | ||||
#include "CGUI.h" | #include "CGUI.h" | ||||
#include "ps/ScreenSize.h" | |||||
#include <algorithm> | #include <algorithm> | ||||
CTooltip::CTooltip() | CTooltip::CTooltip() | ||||
{ | { | ||||
// If the tooltip is an object by itself: | // If the tooltip is an object by itself: | ||||
AddSetting(GUIST_float, "buffer_zone"); | AddSetting(GUIST_float, "buffer_zone"); | ||||
AddSetting(GUIST_CGUIString, "caption"); | AddSetting(GUIST_CGUIString, "caption"); | ||||
▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | case EVAlign_Center: | ||||
break; | break; | ||||
default: | default: | ||||
debug_warn(L"Invalid EVAlign!"); | debug_warn(L"Invalid EVAlign!"); | ||||
} | } | ||||
// Reposition the tooltip if it's falling off the screen: | // Reposition the tooltip if it's falling off the screen: | ||||
extern int g_xres, g_yres; | float screenw = g_ScreenSize.GuiWidth(); | ||||
extern float g_GuiScale; | float screenh = g_ScreenSize.GuiHeight(); | ||||
Stan: static_cast<float>() here and below. | |||||
float screenw = g_xres / g_GuiScale; | |||||
float screenh = g_yres / g_GuiScale; | |||||
if (size.pixel.top < 0.f) | if (size.pixel.top < 0.f) | ||||
size.pixel.bottom -= size.pixel.top, size.pixel.top = 0.f; | size.pixel.bottom -= size.pixel.top, size.pixel.top = 0.f; | ||||
else if (size.pixel.bottom > screenh) | else if (size.pixel.bottom > screenh) | ||||
size.pixel.top -= (size.pixel.bottom-screenh), size.pixel.bottom = screenh; | size.pixel.top -= (size.pixel.bottom-screenh), size.pixel.bottom = screenh; | ||||
if (size.pixel.left < 0.f) | if (size.pixel.left < 0.f) | ||||
size.pixel.right -= size.pixel.left, size.pixel.left = 0.f; | size.pixel.right -= size.pixel.left, size.pixel.left = 0.f; | ||||
Show All 36 Lines |
Wildfire Games · Phabricator
static_cast<float>() here and below.