2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 16:24:55 +00:00

string_view refactor

This commit is contained in:
Jack Andersen
2017-11-12 20:19:18 -10:00
parent 742ab2514f
commit f7ec7bdc0c
345 changed files with 907 additions and 921 deletions

View File

@@ -30,7 +30,7 @@ CGuiFrame::~CGuiFrame()
x8_guiSys.m_registeredFrames.erase(this);
}
CGuiWidget* CGuiFrame::FindWidget(const std::string& name) const
CGuiWidget* CGuiFrame::FindWidget(std::string_view name) const
{
s16 id = x18_idDB.FindWidgetID(name);
if (id == -1)

View File

@@ -50,7 +50,7 @@ public:
CGuiLight* GetFrameLight(int idx) const { return m_indexedLights[idx]; }
CGuiCamera* GetFrameCamera() const { return x14_camera.get(); }
CGuiWidget* FindWidget(const std::string& name) const;
CGuiWidget* FindWidget(std::string_view name) const;
CGuiWidget* FindWidget(s16 id) const;
void SetFrameCamera(std::shared_ptr<CGuiCamera>&& camr) { x14_camera = std::move(camr); }
void SetHeadWidget(std::shared_ptr<CGuiHeadWidget>&& hwig) { xc_headWidget = std::move(hwig); }

View File

@@ -230,7 +230,7 @@ void CGuiTextSupport::SetFontColor(const zeus::CColor& col)
}
}
void CGuiTextSupport::AddText(const std::u16string& str)
void CGuiTextSupport::AddText(std::u16string_view str)
{
if (x60_renderBuf)
{
@@ -242,7 +242,7 @@ void CGuiTextSupport::AddText(const std::u16string& str)
ClearRenderBuffer();
}
void CGuiTextSupport::SetText(const std::u16string& str, bool multipage)
void CGuiTextSupport::SetText(std::u16string_view str, bool multipage)
{
if (x0_string.compare(str))
{
@@ -255,7 +255,7 @@ void CGuiTextSupport::SetText(const std::u16string& str, bool multipage)
}
}
void CGuiTextSupport::SetText(const std::string& str, bool multipage)
void CGuiTextSupport::SetText(std::string_view str, bool multipage)
{
SetText(hecl::UTF8ToChar16(str), multipage);
}

View File

@@ -129,16 +129,16 @@ public:
void SetGeometryColor(const zeus::CColor& col);
void SetOutlineColor(const zeus::CColor& col);
void SetFontColor(const zeus::CColor& col);
void AddText(const std::u16string& str);
void SetText(const std::u16string& str, bool multipage=false);
void SetText(const std::string& str, bool multipage=false);
void AddText(std::u16string_view str);
void SetText(std::u16string_view str, bool multipage=false);
void SetText(std::string_view str, bool multipage=false);
void SetJustification(EJustification j);
void SetVerticalJustification(EVerticalJustification j);
void SetImageBaseline(bool b);
bool GetIsTextSupportFinishedLoading() const;
float GetCurTime() const { return x3c_curTime; }
void SetCurTime(float t) { x3c_curTime = t; }
const std::u16string& GetString() const { return x0_string; }
std::u16string_view GetString() const { return x0_string; }
void SetControlTXTRMap(const std::vector<std::pair<CAssetId, CAssetId>>* txtrMap);
int GetPageCounter() const { return x304_pageCounter; }
int GetTotalPageCount();

View File

@@ -11,15 +11,15 @@ CGuiWidgetIdDB::CGuiWidgetIdDB()
AddWidget("kGSYS_DefaultLightID");
}
s16 CGuiWidgetIdDB::FindWidgetID(const std::string& name) const
s16 CGuiWidgetIdDB::FindWidgetID(std::string_view name) const
{
auto search = x0_dbMap.find(name);
auto search = x0_dbMap.find(name.data());
if (search == x0_dbMap.cend())
return -1;
return search->second;
}
s16 CGuiWidgetIdDB::AddWidget(const std::string& name, s16 id)
s16 CGuiWidgetIdDB::AddWidget(std::string_view name, s16 id)
{
s16 findId = FindWidgetID(name);
if (findId == -1)
@@ -32,7 +32,7 @@ s16 CGuiWidgetIdDB::AddWidget(const std::string& name, s16 id)
return findId;
}
s16 CGuiWidgetIdDB::AddWidget(const std::string& name)
s16 CGuiWidgetIdDB::AddWidget(std::string_view name)
{
s16 findId = FindWidgetID(name);
if (findId == -1)

View File

@@ -13,9 +13,9 @@ class CGuiWidgetIdDB
s16 x14_lastPoolId = 0;
public:
CGuiWidgetIdDB();
s16 FindWidgetID(const std::string& name) const;
s16 AddWidget(const std::string& name, s16 id);
s16 AddWidget(const std::string& name);
s16 FindWidgetID(std::string_view name) const;
s16 AddWidget(std::string_view name, s16 id);
s16 AddWidget(std::string_view name);
};
}

View File

@@ -42,7 +42,7 @@ void CHudBossEnergyInterface::Update(float dt)
}
}
void CHudBossEnergyInterface::SetBossParams(bool visible, const std::u16string& name,
void CHudBossEnergyInterface::SetBossParams(bool visible, std::u16string_view name,
float curEnergy, float maxEnergy)
{
x10_24_visible = visible;

View File

@@ -25,7 +25,7 @@ public:
CHudBossEnergyInterface(CGuiFrame& selHud);
void Update(float dt);
void SetAlpha(float a) { x0_alpha = a; }
void SetBossParams(bool visible, const std::u16string& name,
void SetBossParams(bool visible, std::u16string_view name,
float curEnergy, float maxEnergy);
static std::pair<zeus::CVector3f, zeus::CVector3f> BossEnergyCoordFunc(float t);
};