Changeset View
Changeset View
Standalone View
Standalone View
source/gui/SettingTypes/MouseEventMask.cpp
/* Copyright (C) 2021 Wildfire Games. | /* Copyright (C) 2022 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 All 14 Lines | |||||
#include "maths/Rect.h" | #include "maths/Rect.h" | ||||
#include "maths/Vector2D.h" | #include "maths/Vector2D.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/CacheLoader.h" | #include "ps/CacheLoader.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/CStr.h" | #include "ps/CStr.h" | ||||
#include "scriptinterface/ScriptConversions.h" | #include "scriptinterface/ScriptConversions.h" | ||||
#include <string_view> | |||||
class IGUIObject; | class IGUIObject; | ||||
class IGUISetting; | class IGUISetting; | ||||
namespace | namespace | ||||
{ | { | ||||
const std::string MOUSE_EVENT_MASK = "mouse_event_mask"; | const std::string MOUSE_EVENT_MASK = "mouse_event_mask"; | ||||
} | } | ||||
Show All 38 Lines | |||||
} | } | ||||
class CGUIMouseEventMaskTexture final : public CGUIMouseEventMask::Impl | class CGUIMouseEventMaskTexture final : public CGUIMouseEventMask::Impl | ||||
{ | { | ||||
public: | public: | ||||
static constexpr std::string_view identifier = "texture:"; | static constexpr std::string_view identifier = "texture:"; | ||||
static constexpr size_t specOffset = identifier.size(); | static constexpr size_t specOffset = identifier.size(); | ||||
static std::unique_ptr<CGUIMouseEventMaskTexture> Create(const std::string& spec) | static std::unique_ptr<CGUIMouseEventMaskTexture> Create(const std::string_view spec) | ||||
{ | { | ||||
std::shared_ptr<u8> shapeFile; | std::shared_ptr<u8> shapeFile; | ||||
CCacheLoader loader(g_VFS, L".dds"); | CCacheLoader loader(g_VFS, L".dds"); | ||||
VfsPath sourcePath = VfsPath("art") / L"textures" / L"ui" / spec.substr(specOffset); | VfsPath sourcePath = VfsPath("art") / L"textures" / L"ui" / | ||||
std::string{spec.substr(specOffset)}; | |||||
VfsPath archivePath = loader.ArchiveCachePath(sourcePath); | VfsPath archivePath = loader.ArchiveCachePath(sourcePath); | ||||
Status status; | Status status; | ||||
size_t size; | size_t size; | ||||
if (loader.CanUseArchiveCache(sourcePath, archivePath)) | if (loader.CanUseArchiveCache(sourcePath, archivePath)) | ||||
status = g_VFS->LoadFile(archivePath, shapeFile, size); | status = g_VFS->LoadFile(archivePath, shapeFile, size); | ||||
else | else | ||||
status = g_VFS->LoadFile(sourcePath, shapeFile, size); | status = g_VFS->LoadFile(sourcePath, shapeFile, size); | ||||
if (status != INFO::OK) | if (status != INFO::OK) | ||||
▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator