metaforce/Runtime/GuiSys/CGuiWidgetIdDB.cpp

41 lines
971 B
C++
Raw Normal View History

#include "Runtime/GuiSys/CGuiWidgetIdDB.hpp"
2016-03-11 22:50:15 +00:00
2018-12-08 05:30:43 +00:00
namespace urde {
2016-03-11 22:50:15 +00:00
2018-12-08 05:30:43 +00:00
CGuiWidgetIdDB::CGuiWidgetIdDB() {
AddWidget("kGSYS_DummyWidgetID", 0);
AddWidget("kGSYS_HeadWidgetID", 1);
AddWidget("kGSYS_DefaultCameraID");
AddWidget("kGSYS_DefaultLightID");
2016-03-11 22:50:15 +00:00
}
2018-12-08 05:30:43 +00:00
s16 CGuiWidgetIdDB::FindWidgetID(std::string_view name) const {
auto search = x0_dbMap.find(name.data());
if (search == x0_dbMap.cend())
return -1;
return search->second;
2016-03-11 22:50:15 +00:00
}
2018-12-08 05:30:43 +00:00
s16 CGuiWidgetIdDB::AddWidget(std::string_view name, s16 id) {
s16 findId = FindWidgetID(name);
if (findId == -1) {
if (id >= x14_lastPoolId)
x14_lastPoolId = id;
x0_dbMap.emplace(std::make_pair(name, id));
findId = id;
}
return findId;
2016-03-11 22:50:15 +00:00
}
2018-12-08 05:30:43 +00:00
s16 CGuiWidgetIdDB::AddWidget(std::string_view name) {
s16 findId = FindWidgetID(name);
if (findId == -1) {
++x14_lastPoolId;
x0_dbMap.emplace(std::make_pair(name, x14_lastPoolId));
findId = x14_lastPoolId;
}
return findId;
2016-03-11 22:50:15 +00:00
}
2018-12-08 05:30:43 +00:00
} // namespace urde