Refactor artLockFrameData with FrmImage
This commit is contained in:
parent
e50e26cf87
commit
5b7a676b35
|
@ -301,15 +301,10 @@ void automapShow(bool isInGame, bool isUsingScanner)
|
||||||
int frmIds[AUTOMAP_FRM_COUNT];
|
int frmIds[AUTOMAP_FRM_COUNT];
|
||||||
memcpy(frmIds, gAutomapFrmIds, sizeof(gAutomapFrmIds));
|
memcpy(frmIds, gAutomapFrmIds, sizeof(gAutomapFrmIds));
|
||||||
|
|
||||||
unsigned char* frmData[AUTOMAP_FRM_COUNT];
|
FrmImage frmImages[AUTOMAP_FRM_COUNT];
|
||||||
CacheEntry* frmHandle[AUTOMAP_FRM_COUNT];
|
|
||||||
for (int index = 0; index < AUTOMAP_FRM_COUNT; index++) {
|
for (int index = 0; index < AUTOMAP_FRM_COUNT; index++) {
|
||||||
int fid = buildFid(OBJ_TYPE_INTERFACE, frmIds[index], 0, 0, 0);
|
int fid = buildFid(OBJ_TYPE_INTERFACE, frmIds[index], 0, 0, 0);
|
||||||
frmData[index] = artLockFrameData(fid, 0, 0, &(frmHandle[index]));
|
if (!frmImages[index].lock(fid)) {
|
||||||
if (frmData[index] == NULL) {
|
|
||||||
while (--index >= 0) {
|
|
||||||
artUnlock(frmHandle[index]);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,17 +324,53 @@ void automapShow(bool isInGame, bool isUsingScanner)
|
||||||
int automapWindowY = (screenGetHeight() - AUTOMAP_WINDOW_HEIGHT) / 2;
|
int automapWindowY = (screenGetHeight() - AUTOMAP_WINDOW_HEIGHT) / 2;
|
||||||
int window = windowCreate(automapWindowX, automapWindowY, AUTOMAP_WINDOW_WIDTH, AUTOMAP_WINDOW_HEIGHT, color, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x04);
|
int window = windowCreate(automapWindowX, automapWindowY, AUTOMAP_WINDOW_WIDTH, AUTOMAP_WINDOW_HEIGHT, color, WINDOW_FLAG_0x10 | WINDOW_FLAG_0x04);
|
||||||
|
|
||||||
int scannerBtn = buttonCreate(window, 111, 454, 15, 16, -1, -1, -1, KEY_LOWERCASE_S, frmData[AUTOMAP_FRM_BUTTON_UP], frmData[AUTOMAP_FRM_BUTTON_DOWN], NULL, BUTTON_FLAG_TRANSPARENT);
|
int scannerBtn = buttonCreate(window,
|
||||||
|
111,
|
||||||
|
454,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
KEY_LOWERCASE_S,
|
||||||
|
frmImages[AUTOMAP_FRM_BUTTON_UP].getData(),
|
||||||
|
frmImages[AUTOMAP_FRM_BUTTON_DOWN].getData(),
|
||||||
|
NULL,
|
||||||
|
BUTTON_FLAG_TRANSPARENT);
|
||||||
if (scannerBtn != -1) {
|
if (scannerBtn != -1) {
|
||||||
buttonSetCallbacks(scannerBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
buttonSetCallbacks(scannerBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
int cancelBtn = buttonCreate(window, 277, 454, 15, 16, -1, -1, -1, KEY_ESCAPE, frmData[AUTOMAP_FRM_BUTTON_UP], frmData[AUTOMAP_FRM_BUTTON_DOWN], NULL, BUTTON_FLAG_TRANSPARENT);
|
int cancelBtn = buttonCreate(window,
|
||||||
|
277,
|
||||||
|
454,
|
||||||
|
15,
|
||||||
|
16,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
KEY_ESCAPE,
|
||||||
|
frmImages[AUTOMAP_FRM_BUTTON_UP].getData(),
|
||||||
|
frmImages[AUTOMAP_FRM_BUTTON_DOWN].getData(),
|
||||||
|
NULL,
|
||||||
|
BUTTON_FLAG_TRANSPARENT);
|
||||||
if (cancelBtn != -1) {
|
if (cancelBtn != -1) {
|
||||||
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
||||||
}
|
}
|
||||||
|
|
||||||
int switchBtn = buttonCreate(window, 457, 340, 42, 74, -1, -1, KEY_LOWERCASE_L, KEY_LOWERCASE_H, frmData[AUTOMAP_FRM_SWITCH_UP], frmData[AUTOMAP_FRM_SWITCH_DOWN], NULL, BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x01);
|
int switchBtn = buttonCreate(window,
|
||||||
|
457,
|
||||||
|
340,
|
||||||
|
42,
|
||||||
|
74,
|
||||||
|
-1,
|
||||||
|
-1,
|
||||||
|
KEY_LOWERCASE_L,
|
||||||
|
KEY_LOWERCASE_H,
|
||||||
|
frmImages[AUTOMAP_FRM_SWITCH_UP].getData(),
|
||||||
|
frmImages[AUTOMAP_FRM_SWITCH_DOWN].getData(),
|
||||||
|
NULL,
|
||||||
|
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x01);
|
||||||
if (switchBtn != -1) {
|
if (switchBtn != -1) {
|
||||||
buttonSetCallbacks(switchBtn, _gsound_toggle_butt_press_, _gsound_toggle_butt_press_);
|
buttonSetCallbacks(switchBtn, _gsound_toggle_butt_press_, _gsound_toggle_butt_press_);
|
||||||
}
|
}
|
||||||
|
@ -360,7 +391,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
|
||||||
gAutomapFlags |= AUTOMAP_WITH_SCANNER;
|
gAutomapFlags |= AUTOMAP_WITH_SCANNER;
|
||||||
}
|
}
|
||||||
|
|
||||||
automapRenderInMapWindow(window, elevation, frmData[AUTOMAP_FRM_BACKGROUND], gAutomapFlags);
|
automapRenderInMapWindow(window, elevation, frmImages[AUTOMAP_FRM_BACKGROUND].getData(), gAutomapFlags);
|
||||||
|
|
||||||
bool isoWasEnabled = isoDisable();
|
bool isoWasEnabled = isoDisable();
|
||||||
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
|
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
|
||||||
|
@ -444,7 +475,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (needsRefresh) {
|
if (needsRefresh) {
|
||||||
automapRenderInMapWindow(window, elevation, frmData[AUTOMAP_FRM_BACKGROUND], gAutomapFlags);
|
automapRenderInMapWindow(window, elevation, frmImages[AUTOMAP_FRM_BACKGROUND].getData(), gAutomapFlags);
|
||||||
needsRefresh = false;
|
needsRefresh = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -455,10 +486,6 @@ void automapShow(bool isInGame, bool isUsingScanner)
|
||||||
|
|
||||||
windowDestroy(window);
|
windowDestroy(window);
|
||||||
fontSetCurrent(oldFont);
|
fontSetCurrent(oldFont);
|
||||||
|
|
||||||
for (int index = 0; index < AUTOMAP_FRM_COUNT; index++) {
|
|
||||||
artUnlock(frmHandle[index]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renders automap in Map window.
|
// Renders automap in Map window.
|
||||||
|
|
Loading…
Reference in New Issue