refactor: Make Resources.getString return a string
This commit is contained in:
parent
72432858c3
commit
52ad37ea25
11 changed files with 22 additions and 15 deletions
|
@ -39,7 +39,7 @@ void ItemBlueprint::load(const GffStruct &uti) {
|
|||
_tag = uti.getString("Tag");
|
||||
boost::to_lower(_tag);
|
||||
|
||||
_localizedName = Resources::instance().getString(uti.getInt("LocalizedName")).text;
|
||||
_localizedName = Resources::instance().getString(uti.getInt("LocalizedName"));
|
||||
|
||||
shared_ptr<TwoDaTable> baseItems(Resources::instance().get2DA("baseitems"));
|
||||
int baseItem = uti.getInt("BaseItem");
|
||||
|
|
|
@ -227,10 +227,10 @@ void ClassSelection::onFocusChanged(const string &control, bool focus) {
|
|||
|
||||
ClassButton &button = _classButtons[idx];
|
||||
|
||||
string classText(Resources::instance().getString(g_genderStrRefs[button.config.gender]).text);
|
||||
classText += " " + Resources::instance().getString(g_classStrRefs[button.config.clazz]).text;
|
||||
string classText(Resources::instance().getString(g_genderStrRefs[button.config.gender]));
|
||||
classText += " " + Resources::instance().getString(g_classStrRefs[button.config.clazz]);
|
||||
|
||||
string descText(Resources::instance().getString(g_classDescStrRefs[button.config.clazz]).text);
|
||||
string descText(Resources::instance().getString(g_classDescStrRefs[button.config.clazz]));
|
||||
|
||||
getControl("LBL_CLASS").setTextMessage(classText);
|
||||
getControl("LBL_DESC").setTextMessage(descText);
|
||||
|
|
|
@ -58,10 +58,10 @@ Container::Container(Game *game) :
|
|||
void Container::load() {
|
||||
GUI::load();
|
||||
|
||||
string btnMessage(Resources::instance().getString(kSwitchToResRef).text + " " + Resources::instance().getString(kGiveItemResRef).text);
|
||||
string btnMessage(Resources::instance().getString(kSwitchToResRef) + " " + Resources::instance().getString(kGiveItemResRef));
|
||||
getControl("BTN_GIVEITEMS").setTextMessage(btnMessage);
|
||||
|
||||
string lblMessage(Resources::instance().getString(kInventoryResRef).text);
|
||||
string lblMessage(Resources::instance().getString(kInventoryResRef));
|
||||
getControl("LBL_MESSAGE").setTextMessage(lblMessage);
|
||||
|
||||
configureItemsListBox();
|
||||
|
|
|
@ -304,7 +304,7 @@ void Equipment::updateItems() {
|
|||
if (_selectedSlot != Slot::None) {
|
||||
ListBox::Item lbItem;
|
||||
lbItem.tag = "[none]";
|
||||
lbItem.text = Resources::instance().getString(kStrRefNone).text;
|
||||
lbItem.text = Resources::instance().getString(kStrRefNone);
|
||||
lbItem.icon = Textures::instance().get("inone", TextureType::GUI);
|
||||
|
||||
lbItems.add(move(lbItem));
|
||||
|
|
|
@ -174,7 +174,7 @@ void PartySelection::refreshAvailableCount() {
|
|||
}
|
||||
|
||||
void PartySelection::refreshAcceptButton() {
|
||||
string text(Resources::instance().getString(_added[_selectedNpc] ? g_strRefRemove : g_strRefAdd).text);
|
||||
string text(Resources::instance().getString(_added[_selectedNpc] ? g_strRefRemove : g_strRefAdd));
|
||||
Button &btnAccept = getControl<Button>("BTN_ACCEPT");
|
||||
btnAccept.setTextMessage(text);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ void Door::load(const GffStruct &gffs) {
|
|||
|
||||
int transDestStrRef = gffs.getInt("TransitionDestin");
|
||||
if (transDestStrRef != -1) {
|
||||
_transitionDestin = Resources::instance().getString(transDestStrRef).text;
|
||||
_transitionDestin = Resources::instance().getString(transDestStrRef);
|
||||
}
|
||||
|
||||
string templResRef(gffs.getString("TemplateResRef"));
|
||||
|
|
|
@ -46,7 +46,7 @@ void Trigger::load(const GffStruct &gffs) {
|
|||
|
||||
int transDestIdx = gffs.getInt("TransitionDestin", -1);
|
||||
if (transDestIdx != -1) {
|
||||
_transitionDestin = Resources::instance().getString(transDestIdx).text;
|
||||
_transitionDestin = Resources::instance().getString(transDestIdx);
|
||||
}
|
||||
|
||||
_linkedToModule = gffs.getString("LinkedToModule");
|
||||
|
|
|
@ -160,7 +160,7 @@ void Control::loadText(const GffStruct &gffs) {
|
|||
_text.font = Fonts::instance().get(gffs.getString("FONT"));
|
||||
|
||||
int strRef = gffs.getInt("STRREF");
|
||||
_text.text = strRef == -1 ? gffs.getString("TEXT") : Resources::instance().getString(strRef).text;
|
||||
_text.text = strRef == -1 ? gffs.getString("TEXT") : Resources::instance().getString(strRef);
|
||||
|
||||
_text.color = gffs.getVector("COLOR");
|
||||
_text.align = static_cast<TextAlign>(gffs.getInt("ALIGNMENT", static_cast<int>(TextAlign::CenterCenter)));
|
||||
|
|
|
@ -63,7 +63,7 @@ DlgFile::EntryReply DlgFile::getEntryReply(const GffStruct &gffs) const {
|
|||
|
||||
EntryReply entry;
|
||||
entry.speaker = gffs.getString("Speaker");
|
||||
entry.text = strRef == -1 ? "" : Resources::instance().getString(strRef).text;
|
||||
entry.text = strRef == -1 ? "" : Resources::instance().getString(strRef);
|
||||
entry.voResRef = gffs.getString("VO_ResRef");
|
||||
entry.script = gffs.getString("Script");
|
||||
entry.sound = gffs.getString("Sound");
|
||||
|
|
|
@ -348,8 +348,15 @@ shared_ptr<ByteArray> Resources::getFromExe(uint32_t name, PEResourceType type)
|
|||
return _exeFile.find(name, type);
|
||||
}
|
||||
|
||||
const TalkTableString &Resources::getString(int32_t ref) const {
|
||||
return _tlkFile.table()->getString(ref);
|
||||
const string &Resources::getString(int32_t ref) const {
|
||||
static string empty;
|
||||
|
||||
shared_ptr<TalkTable> table(_tlkFile.table());
|
||||
if (ref == -1 || ref >= table->stringCount()) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
return table->getString(ref).text;
|
||||
}
|
||||
|
||||
const vector<string> &Resources::moduleNames() const {
|
||||
|
|
|
@ -56,7 +56,7 @@ public:
|
|||
std::shared_ptr<ByteArray> getFromExe(uint32_t name, PEResourceType type);
|
||||
std::shared_ptr<TalkTable> getTalkTable(const std::string &resRef);
|
||||
|
||||
const TalkTableString &getString(int32_t ref) const;
|
||||
const std::string &getString(int32_t ref) const;
|
||||
|
||||
const std::vector<std::string> &moduleNames() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue