2019-09-22 21:52:05 +00:00
|
|
|
#include "Runtime/GuiSys/CGuiWidgetIdDB.hpp"
|
2016-03-11 22:50:15 +00:00
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
namespace metaforce {
|
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 {
|
2020-04-11 22:51:39 +00:00
|
|
|
// TODO: Heterogeneous lookup when C++20 available
|
2018-12-08 05:30:43 +00:00
|
|
|
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;
|
2020-03-26 07:55:25 +00:00
|
|
|
x0_dbMap.emplace(name, id);
|
2018-12-08 05:30:43 +00:00
|
|
|
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;
|
2020-03-26 07:55:25 +00:00
|
|
|
x0_dbMap.emplace(name, x14_lastPoolId);
|
2018-12-08 05:30:43 +00:00
|
|
|
findId = x14_lastPoolId;
|
|
|
|
}
|
|
|
|
return findId;
|
2016-03-11 22:50:15 +00:00
|
|
|
}
|
|
|
|
|
2021-04-10 08:42:06 +00:00
|
|
|
} // namespace metaforce
|