From 28423fbc7f566e1238067a340112d411078461e2 Mon Sep 17 00:00:00 2001 From: danij Date: Sun, 30 Nov 2014 20:51:20 +0000 Subject: [PATCH] libcommon: Use the now public ded_t API to lookup Text definitions --- doomsday/plugins/common/src/g_game.cpp | 14 ++++++++------ doomsday/plugins/common/src/hu_menu.cpp | 12 ++++-------- doomsday/plugins/common/src/p_inventory.cpp | 4 ++-- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/doomsday/plugins/common/src/g_game.cpp b/doomsday/plugins/common/src/g_game.cpp index 8ec217353b..0198e6cb02 100644 --- a/doomsday/plugins/common/src/g_game.cpp +++ b/doomsday/plugins/common/src/g_game.cpp @@ -2076,11 +2076,12 @@ String G_EpisodeTitle(String episodeId) if(Record const *episodeDef = Defs().episodes.tryFind("id", episodeId)) { title = episodeDef->gets("title"); + // Perhaps the title string is a reference to a Text definition? - void *ptr; - if(Def_Get(DD_DEF_TEXT, title.toUtf8().constData(), &ptr) != -1) + int textIdx = Defs().getTextNumForName(title.toUtf8().constData()); + if(textIdx >= 0) { - title = (char const *) ptr; // Yes, use the resolved text string. + title = Defs().text[textIdx].text; // Yes, use the resolved text string. } } return title; @@ -2094,11 +2095,12 @@ String G_MapTitle(de::Uri const &mapUri) if(Record const *mapInfo = Defs().mapInfos.tryFind("id", mapUri.compose())) { title = mapInfo->gets("title"); + // Perhaps the title string is a reference to a Text definition? - void *ptr; - if(Def_Get(DD_DEF_TEXT, title.toUtf8().constData(), &ptr) != -1) + int textIdx = Defs().getTextNumForName(title.toUtf8().constData()); + if(textIdx >= 0) { - title = (char const *) ptr; // Yes, use the resolved text string. + title = Defs().text[textIdx].text; // Yes, use the resolved text string. } } diff --git a/doomsday/plugins/common/src/hu_menu.cpp b/doomsday/plugins/common/src/hu_menu.cpp index 209d241cd5..024b7dae44 100644 --- a/doomsday/plugins/common/src/hu_menu.cpp +++ b/doomsday/plugins/common/src/hu_menu.cpp @@ -1802,13 +1802,9 @@ void Hu_MenuInitEpisodePage() for(auto const &pair : episodesById) { Record const &episodeDef = *pair.second->as().record(); + String const episodeId = episodeDef.gets("id"); - String title = episodeDef.gets("title"); - // Perhaps a Text definition? - int textIdx = Defs().getTextNumForName(title.toUtf8().constData()); - if(textIdx >= 0) title = String(Defs().text[textIdx].text); // Yes, use the resolved text string. - - auto *btn = new ButtonWidget(title); + auto *btn = new ButtonWidget(G_EpisodeTitle(episodeId)); btn->setFixedY(y); // Has a menu image been specified? @@ -1841,7 +1837,7 @@ void Hu_MenuInitEpisodePage() if(P_MapExists(startMap.compose().toUtf8().constData())) { btn->setAction(Widget::Deactivated, Hu_MenuSelectEpisode); - btn->setUserValue(episodeDef.gets("id")); + btn->setUserValue(episodeId); } else { @@ -1864,7 +1860,7 @@ void Hu_MenuInitEpisodePage() btn->setFlags(Widget::Disabled); LOG_RES_WARNING("Failed to locate the starting map \"%s\" for episode '%s'." " This episode will not be selectable from the menu") - << startMap << episodeDef.gets("id"); + << startMap << episodeId; } } diff --git a/doomsday/plugins/common/src/p_inventory.cpp b/doomsday/plugins/common/src/p_inventory.cpp index afb81dcc9b..816a432f29 100644 --- a/doomsday/plugins/common/src/p_inventory.cpp +++ b/doomsday/plugins/common/src/p_inventory.cpp @@ -303,9 +303,9 @@ void P_InitInventory() continue; data->type = type; - data->niceName = textenum_t(Def_Get(DD_DEF_TEXT, (char *) def->niceName, NULL)); + data->niceName = textenum_t(Defs().getTextNumForName(def->niceName)); data->action = getActionPtr(def->action); - data->useSnd = sfxenum_t(Def_Get(DD_DEF_SOUND, (char *) def->useSnd, NULL)); + data->useSnd = sfxenum_t(Defs().getSoundNum(def->useSnd)); data->patchId = R_DeclarePatch(def->patch); }