Changeset View
Changeset View
Standalone View
Standalone View
source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 158 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
SDL_Event_ ev = { { 0 } }; | SDL_Event_ ev = { { 0 } }; | ||||
ev.ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; | ev.ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; | ||||
ev.ev.button.button = msg->button; | ev.ev.button.button = msg->button; | ||||
ev.ev.button.state = msg->pressed ? SDL_PRESSED : SDL_RELEASED; | ev.ev.button.state = msg->pressed ? SDL_PRESSED : SDL_RELEASED; | ||||
ev.ev.button.clicks = msg->clicks; | ev.ev.button.clicks = msg->clicks; | ||||
float x, y; | float x, y; | ||||
msg->pos->GetScreenSpace(x, y); | msg->pos->GetScreenSpace(x, y); | ||||
ev.ev.button.x = (u16)clamp((int)x, 0, g_xres); | ev.ev.button.x = static_cast<u16>(Clamp(static_cast<int>(x), 0, g_xres)); | ||||
ev.ev.button.y = (u16)clamp((int)y, 0, g_yres); | ev.ev.button.y = static_cast<u16>(Clamp(static_cast<int>(y), 0, g_yres)); | ||||
Stan: static_cast | |||||
in_dispatch_event(&ev); | in_dispatch_event(&ev); | ||||
} | } | ||||
MESSAGEHANDLER(GuiMouseMotionEvent) | MESSAGEHANDLER(GuiMouseMotionEvent) | ||||
{ | { | ||||
SDL_Event_ ev = { { 0 } }; | SDL_Event_ ev = { { 0 } }; | ||||
ev.ev.type = SDL_MOUSEMOTION; | ev.ev.type = SDL_MOUSEMOTION; | ||||
float x, y; | float x, y; | ||||
msg->pos->GetScreenSpace(x, y); | msg->pos->GetScreenSpace(x, y); | ||||
ev.ev.motion.x = (u16)clamp((int)x, 0, g_xres); | ev.ev.motion.x = static_cast<u16>(Clamp(static_cast<int>(x), 0, g_xres)); | ||||
ev.ev.motion.y = (u16)clamp((int)y, 0, g_yres); | ev.ev.motion.y = static_cast<u16>(Clamp(static_cast<int>(y), 0, g_yres)); | ||||
Not Done Inline Actionsstatic_cast Stan: static_cast | |||||
in_dispatch_event(&ev); | in_dispatch_event(&ev); | ||||
} | } | ||||
MESSAGEHANDLER(GuiKeyEvent) | MESSAGEHANDLER(GuiKeyEvent) | ||||
{ | { | ||||
SDL_Event_ ev = { { 0 } }; | SDL_Event_ ev = { { 0 } }; | ||||
ev.ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; | ev.ev.type = msg->pressed ? SDL_KEYDOWN : SDL_KEYUP; | ||||
ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey; | ev.ev.key.keysym.sym = (SDL_Keycode)(int)msg->sdlkey; | ||||
Show All 19 Lines |
Wildfire Games · Phabricator
static_cast