CHEWY: Use the new text handling code for inventory item usage

This commit is contained in:
Filippos Karapetis 2022-04-13 02:47:42 +03:00
parent fabec17274
commit e3040d29c8
3 changed files with 11 additions and 25 deletions

View File

@ -391,7 +391,6 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
int16 visibleCount = 0;
Common::String itemName;
Common::StringArray itemDesc;
char *txt_adr = nullptr;
char c[2] = { 0 };
int16 ret = -1;
bool endLoop = false;
@ -411,16 +410,14 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
visibleCount = 3;
yoff = 0;
if (ats_nr >= 15000) {
txt_adr = _G(atds)->ats_get_txt(ats_nr - 15000, TXT_MARK_USE, &lineCount, INV_USE_DEF);
//itemDesc = _G(atds)->getTextArray(0, ats_nr - 15000, INV_USE_DEF, TXT_MARK_USE);
} else {
txt_adr = _G(atds)->ats_get_txt(ats_nr, TXT_MARK_USE, &lineCount, INV_USE_DATA);
//itemDesc = _G(atds)->getTextArray(0, ats_nr, TXT_MARK_USE, INV_USE_DATA);
}
if (!txt_adr) {
if (ats_nr >= 15000)
itemDesc = _G(atds)->getTextArray(0, ats_nr - 15000, INV_USE_DEF, -1);
else
itemDesc = _G(atds)->getTextArray(0, ats_nr, INV_USE_DATA, -1);
lineCount = itemDesc.size();
if (itemDesc.size() == 0)
endLoop = true;
}
} else {
endLoop = true;
}
@ -528,18 +525,12 @@ int16 Inventory::look(int16 invent_nr, int16 mode, int16 ats_nr) {
int16 k = 0;
if (mode == INV_ATS_MODE) {
if (itemDesc.size() > 0) {
for (int16 i = startLine; i < lineCount && i < startLine + visibleCount; i++) {
_G(out)->printxy(WIN_LOOK_X, WIN_LOOK_Y + yoff + k * 10, 14, 300,
_G(scr_width), itemDesc[i].c_str());
++k;
}
} else {
for (int16 i = startLine; i < lineCount && i < startLine + visibleCount; i++) {
_G(out)->printxy(WIN_LOOK_X, WIN_LOOK_Y + yoff + k * 10, 14, 300,
_G(scr_width), _G(txt)->strPos(txt_adr, i));
++k;
}
}
_G(cur)->plot_cur();

View File

@ -2296,15 +2296,9 @@ void calc_inv_use_txt(int16 test_nr) {
}
static void calc_inv_get_text(int16 cur_inv, int16 test_nr) {
int16 txt_anz;
const char *s = _G(atds)->ats_get_txt(31, TXT_MARK_USE, &txt_anz, INV_USE_DEF);
//Common::String tmp = _G(atds)->getTextEntry(0, 31, INV_USE_DEF, TXT_MARK_USE);
_G(calc_inv_text_str1) = Common::String::format("%s ", s);
_G(calc_inv_text_str1) = _G(atds)->getTextEntry(0, 31, INV_USE_DEF) + " ";
_G(calc_inv_text_str1) += _G(atds)->getTextEntry(cur_inv, TXT_MARK_NAME, INV_ATS_DATA);
s = _G(atds)->ats_get_txt(32, TXT_MARK_USE, &txt_anz, INV_USE_DEF);
_G(calc_inv_text_str2) = Common::String::format("%s ", s);
_G(calc_inv_text_str2) = _G(atds)->getTextEntry(0, 32, INV_USE_DEF) + " ";
_G(calc_inv_text_str2) += _G(atds)->getTextEntry(test_nr, TXT_MARK_NAME, INV_ATS_DATA);
}

View File

@ -102,6 +102,7 @@ TextEntry *Text::getText(uint chunk, uint entry, int type, int subEntry) {
case INV_USE_DEF:
chunk += kADSTextMax + kATSTextMax + kAADTextMax + kINVTextMax;
isInvDesc = true;
isText = true;
break;
case INV_ATS_DATA:
chunk += kADSTextMax + kATSTextMax + kAADTextMax;