mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Use string_view in more places and reduce the number of empty string literals
This commit is contained in:
parent
5b36ea0179
commit
5491512905
45 changed files with 224 additions and 221 deletions
|
@ -66,20 +66,20 @@ namespace SDLUtil
|
|||
}
|
||||
}
|
||||
|
||||
void SDLCursorManager::cursorChanged(const std::string& name)
|
||||
void SDLCursorManager::cursorChanged(std::string_view name)
|
||||
{
|
||||
mCurrentCursor = name;
|
||||
_setGUICursor(name);
|
||||
_setGUICursor(mCurrentCursor);
|
||||
}
|
||||
|
||||
void SDLCursorManager::_setGUICursor(const std::string& name)
|
||||
void SDLCursorManager::_setGUICursor(std::string_view name)
|
||||
{
|
||||
auto it = mCursorMap.find(name);
|
||||
if (it != mCursorMap.end())
|
||||
SDL_SetCursor(it->second);
|
||||
}
|
||||
|
||||
void SDLCursorManager::createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
void SDLCursorManager::createCursor(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
Uint8 hotspot_y, int cursorWidth, int cursorHeight)
|
||||
{
|
||||
#ifndef ANDROID
|
||||
|
@ -128,7 +128,7 @@ namespace SDLUtil
|
|||
return SDLUtil::SurfaceUniquePtr(targetSurface, SDL_FreeSurface);
|
||||
}
|
||||
|
||||
void SDLCursorManager::_createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image,
|
||||
void SDLCursorManager::_createCursorFromResource(std::string_view name, int rotDegrees, osg::Image* image,
|
||||
Uint8 hotspot_x, Uint8 hotspot_y, int cursorWidth, int cursorHeight)
|
||||
{
|
||||
if (mCursorMap.find(name) != mCursorMap.end())
|
||||
|
@ -141,7 +141,7 @@ namespace SDLUtil
|
|||
// set the cursor and store it for later
|
||||
SDL_Cursor* curs = SDL_CreateColorCursor(surface.get(), hotspot_x, hotspot_y);
|
||||
|
||||
mCursorMap.insert(CursorMap::value_type(std::string(name), curs));
|
||||
mCursorMap.emplace(name, curs);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
|
|
@ -27,19 +27,19 @@ namespace SDLUtil
|
|||
|
||||
/// \brief Tell the manager that the cursor has changed, giving the
|
||||
/// name of the cursor we changed to ("arrow", "ibeam", etc)
|
||||
virtual void cursorChanged(const std::string& name);
|
||||
virtual void cursorChanged(std::string_view name);
|
||||
|
||||
virtual void createCursor(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
virtual void createCursor(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
Uint8 hotspot_y, int cursorWidth, int cursorHeight);
|
||||
|
||||
private:
|
||||
void _createCursorFromResource(const std::string& name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
void _createCursorFromResource(std::string_view name, int rotDegrees, osg::Image* image, Uint8 hotspot_x,
|
||||
Uint8 hotspot_y, int cursorWidth, int cursorHeight);
|
||||
void _putPixel(SDL_Surface* surface, int x, int y, Uint32 pixel);
|
||||
|
||||
void _setGUICursor(const std::string& name);
|
||||
void _setGUICursor(std::string_view name);
|
||||
|
||||
typedef std::map<std::string, SDL_Cursor*> CursorMap;
|
||||
typedef std::map<std::string, SDL_Cursor*, std::less<>> CursorMap;
|
||||
CursorMap mCursorMap;
|
||||
|
||||
std::string mCurrentCursor;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue