Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
etorth committed Dec 3, 2024
1 parent 13a227a commit 6d3f3b0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 42 deletions.
2 changes: 1 addition & 1 deletion client/src/guimanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ bool GUIManager::processEventDefault(const SDL_Event &event, bool valid)
return tookEvent;
}

Widget *GUIManager::getWidget(const std::string &name)
Widget *GUIManager::getWidget(const std::string_view &name)
{
if(name == "InventoryBoard"){
return &m_inventoryBoard;
Expand Down
4 changes: 2 additions & 2 deletions client/src/guimanager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ class GUIManager: public Widget
bool processEventDefault(const SDL_Event &, bool) override;

public:
Widget *getWidget(const std::string &);
Widget *getWidget(const std::string_view &);

public:
const Widget *getWidget(const std::string &name) const
const Widget *getWidget(const std::string_view &name) const
{
return const_cast<GUIManager *>(this)->getWidget(name);
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/processrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ void ProcessRun::draw() const

if(m_drawMagicKey){
int magicKeyOffX = 0;
for(const auto &[magicID, magicKey]: dynamic_cast<const SkillBoard *>(m_guiManager.getWidget("SkillBoard"))->getConfig().getMagicKeyList()){
for(const auto &[magicID, magicKey]: dynamic_cast<const SkillBoard *>(this->getWidget("SkillBoard"))->getConfig().getMagicKeyList()){
if(const auto &iconGfx = SkillBoard::getMagicIconGfx(magicID); iconGfx && iconGfx.magicIcon != SYS_U32NIL){
if(auto texPtr = g_progUseDB->retrieve(iconGfx.magicIcon + to_u32(0X00001000))){
g_sdlDevice->drawTexture(texPtr, magicKeyOffX, 0);
Expand Down
22 changes: 11 additions & 11 deletions client/src/processrun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,9 @@ class ProcessRun: public Process
void queryInvOp(int, uint32_t, uint32_t) const;

public:
Widget *getWidget(const std::string &widgetName)
auto getWidget(this auto && self, const std::string_view &widgetName)
{
return getGUIManager()->getWidget(widgetName);
}

const Widget *getWidget(const std::string &widgetName) const
{
return const_cast<ProcessRun *>(this)->getWidget(widgetName);
return self.getGUIManager()->getWidget(widgetName);
}

public:
Expand All @@ -405,9 +400,9 @@ class ProcessRun: public Process
std::tuple<int, int> getACNum(const std::string &) const;

public:
GUIManager *getGUIManager()
auto getGUIManager(this auto && self)
{
return std::addressof(m_guiManager);
return std::addressof(self.m_guiManager);
}

public:
Expand Down Expand Up @@ -486,8 +481,13 @@ class ProcessRun: public Process
void setCursor(int);

public:
template<int CfgIndex> auto getRuntimeConfig() const
// template<int CfgIndex> auto getRuntimeConfig() const
// {
// return SDRuntimeConfig_getConfig<CfgIndex>(dynamic_cast<const RuntimeConfigBoard *>(getWidget("RuntimeConfigBoard"))->getConfig());
// }

template<int CfgIndex> auto getRuntimeConfig(this auto && self)
{
return SDRuntimeConfig_getConfig<CfgIndex>(dynamic_cast<const RuntimeConfigBoard *>(getWidget("RuntimeConfigBoard"))->getConfig());
return SDRuntimeConfig_getConfig<CfgIndex>(dynamic_cast<const RuntimeConfigBoard *>(self.getWidget("RuntimeConfigBoard"))->getConfig());
}
};
39 changes: 12 additions & 27 deletions client/src/xmltypeset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,55 +358,40 @@ class XMLTypeset // means XMLParagraph typeset
int LineFullWidth(int) const;

public:
const TOKEN *getToken(int argX, int argY) const
auto getToken(this auto && self, int argX, int argY)
{
if(!tokenLocValid(argX, argY)){
if(!self.tokenLocValid(argX, argY)){
throw fflerror("invalid token location: (%d, %d)", argX, argY);
}
return &(m_lineList[argY].content[argX]);
}

TOKEN *getToken(int argX, int argY)
{
return const_cast<TOKEN *>(static_cast<const XMLTypeset *>(this)->getToken(argX, argY));
return std::addressof(self.m_lineList[argY].content[argX]);
}

public:
const TOKEN *GetLineBackToken(int argLine) const
auto GetLineBackToken(this auto && self, int argLine)
{
if(!lineValid(argLine)){
if(!self.lineValid(argLine)){
throw fflerror("invalid line: %d", argLine);
}

if(lineTokenCount(argLine) == 0){
if(self.lineTokenCount(argLine) == 0){
throw fflerror("invalie empty line: %d", argLine);
}

return getToken(lineTokenCount(argLine) - 1, argLine);
}

TOKEN *GetLineBackToken(int argLine)
{
return const_cast<TOKEN *>(static_cast<const XMLTypeset *>(this)->GetLineBackToken(argLine));
return self.getToken(self.lineTokenCount(argLine) - 1, argLine);
}

public:
const TOKEN *GetBackToken() const
auto GetBackToken(this auto && self)
{
if(lineCount() == 0){
if(self.lineCount() == 0){
throw fflerror("empty board");
}

if(lineTokenCount(lineCount() - 1) == 0){
throw fflerror("invalie empty line: %d", lineCount() - 1);
if(self.lineTokenCount(self.lineCount() - 1) == 0){
throw fflerror("invalie empty line: %d", self.lineCount() - 1);
}

return GetLineBackToken(lineCount() - 1);
}

TOKEN *GetBackToken()
{
return const_cast<TOKEN *>(static_cast<const XMLTypeset *>(this)->GetBackToken());
return self.GetLineBackToken(self.lineCount() - 1);
}

private:
Expand Down

0 comments on commit 6d3f3b0

Please sign in to comment.