Refactor artLockFrameData with FrmImage

This commit is contained in:
Alexander Batalov 2022-09-26 11:55:06 +03:00
parent 2e5be31ed4
commit 4aae167bd8
1 changed files with 96 additions and 122 deletions

View File

@ -293,27 +293,15 @@ static PreferenceDescription gPreferenceDescriptions[PREF_COUNT] = {
{ 2, 0, 374, 451, 0, 0, { 207, 218, 0, 0 }, 0, GAME_CONFIG_MOUSE_SENSITIVITY_KEY, 1.0, 2.5, NULL },
};
// 0x6637D0
static Size gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_COUNT];
// 0x6637E8
static MessageList gOptionsMessageList;
// 0x6637F0
static Size gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_COUNT];
// 0x663840
static MessageListItem gOptionsMessageListItem;
// 0x663850
static unsigned char* gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_COUNT];
// 0x663878
static unsigned char* _opbtns[OPTIONS_WINDOW_BUTTONS_COUNT];
// 0x6638A0
static CacheEntry* gPreferencesWindowFrmHandles[PREFERENCES_WINDOW_FRM_COUNT];
// 0x6638C8
static double gPreferencesTextBaseDelay2;
@ -347,12 +335,6 @@ static int gPreferencesWindow;
// 0x663908
static unsigned char* gOptionsWindowBuffer;
// 0x66390C
static CacheEntry* gOptionsWindowFrmHandles[OPTIONS_WINDOW_FRM_COUNT];
// 0x663918
static unsigned char* gOptionsWindowFrmData[OPTIONS_WINDOW_FRM_COUNT];
// 0x663924
static int gPreferencesGameDifficulty2;
@ -467,6 +449,9 @@ int gPreferencesGameDifficulty1;
// 0x6639C0
int gPreferencesCombatLooks1;
static FrmImage _optionsFrmImages[OPTIONS_WINDOW_FRM_COUNT];
static FrmImage _preferencesFrmImages[PREFERENCES_WINDOW_FRM_COUNT];
// 0x48FC48
int showOptions()
{
@ -577,11 +562,9 @@ static int optionsWindowInit()
for (int index = 0; index < OPTIONS_WINDOW_FRM_COUNT; index++) {
int fid = buildFid(OBJ_TYPE_INTERFACE, gOptionsWindowFrmIds[index], 0, 0, 0);
gOptionsWindowFrmData[index] = artLockFrameDataReturningSize(fid, &(gOptionsWindowFrmHandles[index]), &(gOptionsWindowFrmSizes[index].width), &(gOptionsWindowFrmSizes[index].height));
if (gOptionsWindowFrmData[index] == NULL) {
if (!_optionsFrmImages[index].lock(fid)) {
while (--index >= 0) {
artUnlock(gOptionsWindowFrmHandles[index]);
_optionsFrmImages[index].unlock();
}
messageListFree(&gOptionsMessageList);
@ -592,14 +575,14 @@ static int optionsWindowInit()
int cycle = 0;
for (int index = 0; index < OPTIONS_WINDOW_BUTTONS_COUNT; index++) {
_opbtns[index] = (unsigned char*)internal_malloc(gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height + 1024);
_opbtns[index] = (unsigned char*)internal_malloc(_optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth() * _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getHeight() + 1024);
if (_opbtns[index] == NULL) {
while (--index >= 0) {
internal_free(_opbtns[index]);
}
for (int index = 0; index < OPTIONS_WINDOW_FRM_COUNT; index++) {
artUnlock(gOptionsWindowFrmHandles[index]);
_optionsFrmImages[index].unlock();
}
messageListFree(&gOptionsMessageList);
@ -609,15 +592,15 @@ static int optionsWindowInit()
cycle = cycle ^ 1;
memcpy(_opbtns[index], gOptionsWindowFrmData[cycle + 1], gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height);
memcpy(_opbtns[index], _optionsFrmImages[cycle + 1].getData(), _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth() * _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getHeight());
}
int optionsWindowX = (screenGetWidth() - gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BACKGROUND].width) / 2;
int optionsWindowY = (screenGetHeight() - gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BACKGROUND].height) / 2 - 60;
int optionsWindowX = (screenGetWidth() - _optionsFrmImages[OPTIONS_WINDOW_FRM_BACKGROUND].getWidth()) / 2;
int optionsWindowY = (screenGetHeight() - _optionsFrmImages[OPTIONS_WINDOW_FRM_BACKGROUND].getHeight()) / 2 - 60;
gOptionsWindow = windowCreate(optionsWindowX,
optionsWindowY,
gOptionsWindowFrmSizes[0].width,
gOptionsWindowFrmSizes[0].height,
_optionsFrmImages[0].getWidth(),
_optionsFrmImages[0].getHeight(),
256,
WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
@ -627,7 +610,7 @@ static int optionsWindowInit()
}
for (int index = 0; index < OPTIONS_WINDOW_FRM_COUNT; index++) {
artUnlock(gOptionsWindowFrmHandles[index]);
_optionsFrmImages[index].unlock();
}
messageListFree(&gOptionsMessageList);
@ -645,11 +628,11 @@ static int optionsWindowInit()
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
gOptionsWindowBuffer = windowGetBuffer(gOptionsWindow);
memcpy(gOptionsWindowBuffer, gOptionsWindowFrmData[OPTIONS_WINDOW_FRM_BACKGROUND], gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BACKGROUND].width * gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BACKGROUND].height);
memcpy(gOptionsWindowBuffer, _optionsFrmImages[OPTIONS_WINDOW_FRM_BACKGROUND].getData(), _optionsFrmImages[OPTIONS_WINDOW_FRM_BACKGROUND].getWidth() * _optionsFrmImages[OPTIONS_WINDOW_FRM_BACKGROUND].getHeight());
fontSetCurrent(103);
int textY = (gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height - fontGetLineHeight()) / 2 + 1;
int textY = (_optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getHeight() - fontGetLineHeight()) / 2 + 1;
int buttonY = 17;
for (int index = 0; index < OPTIONS_WINDOW_BUTTONS_COUNT; index += 2) {
@ -658,20 +641,32 @@ static int optionsWindowInit()
const char* msg = getmsg(&gOptionsMessageList, &gOptionsMessageListItem, index / 2);
strcpy(text, msg);
int textX = (gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width - fontGetStringWidth(text)) / 2;
int textX = (_optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth() - fontGetStringWidth(text)) / 2;
if (textX < 0) {
textX = 0;
}
fontDrawText(_opbtns[index] + gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * textY + textX, text, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width, _colorTable[18979]);
fontDrawText(_opbtns[index + 1] + gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width * textY + textX, text, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width, _colorTable[14723]);
fontDrawText(_opbtns[index] + _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth() * textY + textX, text, _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth(), _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth(), _colorTable[18979]);
fontDrawText(_opbtns[index + 1] + _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth() * textY + textX, text, _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth(), _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth(), _colorTable[14723]);
int btn = buttonCreate(gOptionsWindow, 13, buttonY, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].width, gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height, -1, -1, -1, index / 2 + 500, _opbtns[index], _opbtns[index + 1], NULL, 32);
int btn = buttonCreate(gOptionsWindow,
13,
buttonY,
_optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getWidth(),
_optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getHeight(),
-1,
-1,
-1,
index / 2 + 500,
_opbtns[index],
_opbtns[index + 1],
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
buttonSetCallbacks(btn, _gsound_lrg_butt_press, _gsound_lrg_butt_release);
}
buttonY += gOptionsWindowFrmSizes[OPTIONS_WINDOW_FRM_BUTTON_ON].height + 3;
buttonY += _optionsFrmImages[OPTIONS_WINDOW_FRM_BUTTON_ON].getHeight() + 3;
}
fontSetCurrent(101);
@ -693,7 +688,7 @@ static int optionsWindowFree()
}
for (int index = 0; index < OPTIONS_WINDOW_FRM_COUNT; index++) {
artUnlock(gOptionsWindowFrmHandles[index]);
_optionsFrmImages[index].unlock();
}
if (gOptionsWindowGameMouseObjectsWasVisible) {
@ -710,13 +705,6 @@ static int optionsWindowFree()
// 0x4902B0
int showPause(bool a1)
{
int graphicIds[PAUSE_WINDOW_FRM_COUNT];
unsigned char* frmData[PAUSE_WINDOW_FRM_COUNT];
CacheEntry* frmHandles[PAUSE_WINDOW_FRM_COUNT];
Size frmSizes[PAUSE_WINDOW_FRM_COUNT];
memcpy(graphicIds, gPauseWindowFrmIds, sizeof(gPauseWindowFrmIds));
bool gameMouseWasVisible;
if (!a1) {
gOptionsWindowIsoWasEnabled = isoDisable();
@ -731,14 +719,10 @@ int showPause(bool a1)
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
_ShadeScreen(a1);
FrmImage frmImages[PAUSE_WINDOW_FRM_COUNT];
for (int index = 0; index < PAUSE_WINDOW_FRM_COUNT; index++) {
int fid = buildFid(OBJ_TYPE_INTERFACE, graphicIds[index], 0, 0, 0);
frmData[index] = artLockFrameDataReturningSize(fid, &(frmHandles[index]), &(frmSizes[index].width), &(frmSizes[index].height));
if (frmData[index] == NULL) {
while (--index >= 0) {
artUnlock(frmHandles[index]);
}
int fid = buildFid(OBJ_TYPE_INTERFACE, gPauseWindowFrmIds[index], 0, 0, 0);
if (!frmImages[index].lock(fid)) {
debugPrint("\n** Error loading pause window graphics! **\n");
return -1;
}
@ -756,8 +740,8 @@ int showPause(bool a1)
return -1;
}
int pauseWindowX = (screenGetWidth() - frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width) / 2;
int pauseWindowY = (screenGetHeight() - frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].height) / 2;
int pauseWindowX = (screenGetWidth() - frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth()) / 2;
int pauseWindowY = (screenGetHeight() - frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getHeight()) / 2;
if (a1) {
pauseWindowX -= 65;
@ -768,15 +752,11 @@ int showPause(bool a1)
int window = windowCreate(pauseWindowX,
pauseWindowY,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].height,
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth(),
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getHeight(),
256,
WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (window == -1) {
for (int index = 0; index < PAUSE_WINDOW_FRM_COUNT; index++) {
artUnlock(frmHandles[index]);
}
messageListFree(&gOptionsMessageList);
debugPrint("\n** Error opening pause window! **\n");
@ -785,15 +765,15 @@ int showPause(bool a1)
unsigned char* windowBuffer = windowGetBuffer(window);
memcpy(windowBuffer,
frmData[PAUSE_WINDOW_FRM_BACKGROUND],
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width * frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].height);
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getData(),
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth() * frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getHeight());
blitBufferToBufferTrans(frmData[PAUSE_WINDOW_FRM_DONE_BOX],
frmSizes[PAUSE_WINDOW_FRM_DONE_BOX].width,
frmSizes[PAUSE_WINDOW_FRM_DONE_BOX].height,
frmSizes[PAUSE_WINDOW_FRM_DONE_BOX].width,
windowBuffer + frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width * 42 + 13,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width);
blitBufferToBufferTrans(frmImages[PAUSE_WINDOW_FRM_DONE_BOX].getData(),
frmImages[PAUSE_WINDOW_FRM_DONE_BOX].getWidth(),
frmImages[PAUSE_WINDOW_FRM_DONE_BOX].getHeight(),
frmImages[PAUSE_WINDOW_FRM_DONE_BOX].getWidth(),
windowBuffer + frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth() * 42 + 13,
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth());
gOptionsWindowOldFont = fontGetCurrent();
fontSetCurrent(103);
@ -801,10 +781,10 @@ int showPause(bool a1)
char* messageItemText;
messageItemText = getmsg(&gOptionsMessageList, &gOptionsMessageListItem, 300);
fontDrawText(windowBuffer + frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width * 45 + 52,
fontDrawText(windowBuffer + frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth() * 45 + 52,
messageItemText,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width,
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth(),
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth(),
_colorTable[18979]);
fontSetCurrent(104);
@ -813,23 +793,23 @@ int showPause(bool a1)
strcpy(path, messageItemText);
int length = fontGetStringWidth(path);
fontDrawText(windowBuffer + frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width * 10 + 2 + (frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width - length) / 2,
fontDrawText(windowBuffer + frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth() * 10 + 2 + (frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth() - length) / 2,
path,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width,
frmSizes[PAUSE_WINDOW_FRM_BACKGROUND].width,
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth(),
frmImages[PAUSE_WINDOW_FRM_BACKGROUND].getWidth(),
_colorTable[18979]);
int doneBtn = buttonCreate(window,
26,
46,
frmSizes[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP].width,
frmSizes[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP].height,
frmImages[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getWidth(),
frmImages[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getHeight(),
-1,
-1,
-1,
504,
frmData[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP],
frmData[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN],
frmImages[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getData(),
frmImages[PAUSE_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getData(),
NULL,
BUTTON_FLAG_TRANSPARENT);
if (doneBtn != -1) {
@ -866,11 +846,6 @@ int showPause(bool a1)
}
windowDestroy(window);
for (int index = 0; index < PAUSE_WINDOW_FRM_COUNT; index++) {
artUnlock(frmHandles[index]);
}
messageListFree(&gOptionsMessageList);
if (!a1) {
@ -1100,7 +1075,7 @@ static void _UpdateThing(int index)
int offsets[PRIMARY_PREF_COUNT];
memcpy(offsets, dword_48FC1C, sizeof(dword_48FC1C));
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + 640 * offsets[primaryOptionIndex] + 23, 160, 54, 640, gPreferencesWindowBuffer + 640 * offsets[primaryOptionIndex] + 23, 640);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + 640 * offsets[primaryOptionIndex] + 23, 160, 54, 640, gPreferencesWindowBuffer + 640 * offsets[primaryOptionIndex] + 23, 640);
for (int valueIndex = 0; valueIndex < meta->valuesCount; valueIndex++) {
const char* text = getmsg(&gOptionsMessageList, &gOptionsMessageListItem, meta->labelIds[valueIndex]);
@ -1145,14 +1120,14 @@ static void _UpdateThing(int index)
}
int value = *(meta->valuePtr);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_PRIMARY_SWITCH] + (46 * 47) * value, 46, 47, 46, gPreferencesWindowBuffer + 640 * meta->knobY + meta->knobX, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_PRIMARY_SWITCH].getData() + (46 * 47) * value, 46, 47, 46, gPreferencesWindowBuffer + 640 * meta->knobY + meta->knobX, 640);
} else if (index >= FIRST_SECONDARY_PREF && index <= LAST_SECONDARY_PREF) {
int secondaryOptionIndex = index - FIRST_SECONDARY_PREF;
int offsets[SECONDARY_PREF_COUNT];
memcpy(offsets, dword_48FC30, sizeof(dword_48FC30));
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + 640 * offsets[secondaryOptionIndex] + 251, 113, 34, 640, gPreferencesWindowBuffer + 640 * offsets[secondaryOptionIndex] + 251, 640);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + 640 * offsets[secondaryOptionIndex] + 251, 113, 34, 640, gPreferencesWindowBuffer + 640 * offsets[secondaryOptionIndex] + 251, 640);
// Secondary options are booleans, so it's index is also it's value.
for (int value = 0; value < 2; value++) {
@ -1173,9 +1148,9 @@ static void _UpdateThing(int index)
if (index == PREF_COMBAT_MESSAGES) {
value ^= 1;
}
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_SECONDARY_SWITCH] + (22 * 25) * value, 22, 25, 22, gPreferencesWindowBuffer + 640 * meta->knobY + meta->knobX, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_SECONDARY_SWITCH].getData() + (22 * 25) * value, 22, 25, 22, gPreferencesWindowBuffer + 640 * meta->knobY + meta->knobX, 640);
} else if (index >= FIRST_RANGE_PREF && index <= LAST_RANGE_PREF) {
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + 640 * (meta->knobY - 12) + 384, 240, 24, 640, gPreferencesWindowBuffer + 640 * (meta->knobY - 12) + 384, 640);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + 640 * (meta->knobY - 12) + 384, 240, 24, 640, gPreferencesWindowBuffer + 640 * (meta->knobY - 12) + 384, 640);
switch (index) {
case PREF_COMBAT_SPEED:
if (1) {
@ -1183,7 +1158,7 @@ static void _UpdateThing(int index)
value = std::clamp(value, 0.0, 50.0);
int x = (int)((value - meta->minValue) * 219.0 / (meta->maxValue - meta->minValue) + 384.0);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_OFF], 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_OFF].getData(), 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
}
break;
case PREF_TEXT_BASE_DELAY:
@ -1191,7 +1166,7 @@ static void _UpdateThing(int index)
gPreferencesTextBaseDelay1 = std::clamp(gPreferencesTextBaseDelay1, 1.0, 6.0);
int x = (int)((6.0 - gPreferencesTextBaseDelay1) * 43.8 + 384.0);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_OFF], 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_OFF].getData(), 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
double value = (gPreferencesTextBaseDelay1 - 1.0) * 0.2 * 2.0;
value = std::clamp(value, 0.0, 2.0);
@ -1209,7 +1184,7 @@ static void _UpdateThing(int index)
value = std::clamp(value, meta->minValue, meta->maxValue);
int x = (int)((value - meta->minValue) * 219.0 / (meta->maxValue - meta->minValue) + 384.0);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_OFF], 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_OFF].getData(), 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
switch (index) {
case PREF_MASTER_VOLUME:
@ -1232,7 +1207,7 @@ static void _UpdateThing(int index)
gPreferencesBrightness1 = std::clamp(gPreferencesBrightness1, 1.0, 1.17999267578125);
int x = (int)((gPreferencesBrightness1 - meta->minValue) * (219.0 / (meta->maxValue - meta->minValue)) + 384.0);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_OFF], 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_OFF].getData(), 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
colorSetBrightness(gPreferencesBrightness1);
}
@ -1242,7 +1217,7 @@ static void _UpdateThing(int index)
gPreferencesMouseSensitivity1 = std::clamp(gPreferencesMouseSensitivity1, 1.0, 2.5);
int x = (int)((gPreferencesMouseSensitivity1 - meta->minValue) * (219.0 / (meta->maxValue - meta->minValue)) + 384.0);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_OFF], 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_OFF].getData(), 21, 12, 21, gPreferencesWindowBuffer + 640 * meta->knobY + x, 640);
mouseSetSensitivity(gPreferencesMouseSensitivity1);
}
@ -1501,10 +1476,9 @@ static int preferencesWindowInit()
for (i = 0; i < PREFERENCES_WINDOW_FRM_COUNT; i++) {
fid = buildFid(OBJ_TYPE_INTERFACE, gPreferencesWindowFrmIds[i], 0, 0, 0);
gPreferencesWindowFrmData[i] = artLockFrameDataReturningSize(fid, &(gPreferencesWindowFrmHandles[i]), &(gPreferencesWindowFrmSizes[i].width), &(gPreferencesWindowFrmSizes[i].height));
if (gPreferencesWindowFrmData[i] == NULL) {
for (; i != 0; i--) {
artUnlock(gPreferencesWindowFrmHandles[i - 1]);
if (!_preferencesFrmImages[i].lock(fid)) {
while (--i >= 0) {
_preferencesFrmImages[i].unlock();
}
return -1;
}
@ -1522,15 +1496,15 @@ static int preferencesWindowInit()
WINDOW_FLAG_0x10 | WINDOW_FLAG_0x02);
if (gPreferencesWindow == -1) {
for (i = 0; i < PREFERENCES_WINDOW_FRM_COUNT; i++) {
artUnlock(gPreferencesWindowFrmHandles[i]);
_preferencesFrmImages[i].unlock();
}
return -1;
}
gPreferencesWindowBuffer = windowGetBuffer(gPreferencesWindow);
memcpy(gPreferencesWindowBuffer,
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND],
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_BACKGROUND].width * gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_BACKGROUND].height);
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getWidth() * _preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getHeight());
fontSetCurrent(104);
@ -1618,14 +1592,14 @@ static int preferencesWindowInit()
_plyrspdbid = buttonCreate(gPreferencesWindow,
383,
68,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_CHECKBOX_OFF].width,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_CHECKBOX_ON].height,
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_CHECKBOX_OFF].getWidth(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_CHECKBOX_ON].getHeight(),
-1,
-1,
524,
524,
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_CHECKBOX_OFF],
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_CHECKBOX_ON],
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_CHECKBOX_OFF].getData(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_CHECKBOX_ON].getData(),
NULL,
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x01 | BUTTON_FLAG_0x02);
if (_plyrspdbid != -1) {
@ -1638,14 +1612,14 @@ static int preferencesWindowInit()
btn = buttonCreate(gPreferencesWindow,
23,
450,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].width,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].height,
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getWidth(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getHeight(),
-1,
-1,
-1,
527,
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP],
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN],
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getData(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getData(),
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
@ -1656,14 +1630,14 @@ static int preferencesWindowInit()
btn = buttonCreate(gPreferencesWindow,
148,
450,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].width,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].height,
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getWidth(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getHeight(),
-1,
-1,
-1,
504,
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP],
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN],
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getData(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getData(),
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
@ -1674,14 +1648,14 @@ static int preferencesWindowInit()
btn = buttonCreate(gPreferencesWindow,
263,
450,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].width,
gPreferencesWindowFrmSizes[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].height,
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getWidth(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getHeight(),
-1,
-1,
-1,
528,
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP],
gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN],
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_UP].getData(),
_preferencesFrmImages[PREFERENCES_WINDOW_FRM_LITTLE_RED_BUTTON_DOWN].getData(),
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
@ -1707,7 +1681,7 @@ static int preferencesWindowFree()
windowDestroy(gPreferencesWindow);
for (int index = 0; index < PREFERENCES_WINDOW_FRM_COUNT; index++) {
artUnlock(gPreferencesWindowFrmHandles[index]);
_preferencesFrmImages[index].unlock();
}
return 0;
@ -1912,8 +1886,8 @@ static void _DoThing(int eventCode)
int knobX = (int)(219.0 / (meta->maxValue - meta->minValue));
int v31 = (int)((value - meta->minValue) * (219.0 / (meta->maxValue - meta->minValue)) + 384.0);
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + PREFERENCES_WINDOW_WIDTH * meta->knobY + 384, 240, 12, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + 384, PREFERENCES_WINDOW_WIDTH);
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_ON], 21, 12, 21, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + v31, PREFERENCES_WINDOW_WIDTH);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + PREFERENCES_WINDOW_WIDTH * meta->knobY + 384, 240, 12, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + 384, PREFERENCES_WINDOW_WIDTH);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_ON].getData(), 21, 12, 21, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + v31, PREFERENCES_WINDOW_WIDTH);
windowRefresh(gPreferencesWindow);
@ -2002,7 +1976,7 @@ static void _DoThing(int eventCode)
if (v52) {
int off = PREFERENCES_WINDOW_WIDTH * (meta->knobY - 12) + 384;
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + off, 240, 24, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + off, PREFERENCES_WINDOW_WIDTH);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + off, 240, 24, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + off, PREFERENCES_WINDOW_WIDTH);
for (int optionIndex = 0; optionIndex < meta->valuesCount; optionIndex++) {
const char* str = getmsg(&gOptionsMessageList, &gOptionsMessageListItem, meta->labelIds[optionIndex]);
@ -2051,10 +2025,10 @@ static void _DoThing(int eventCode)
}
} else {
int off = PREFERENCES_WINDOW_WIDTH * meta->knobY + 384;
blitBufferToBuffer(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_BACKGROUND] + off, 240, 12, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + off, PREFERENCES_WINDOW_WIDTH);
blitBufferToBuffer(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_BACKGROUND].getData() + off, 240, 12, PREFERENCES_WINDOW_WIDTH, gPreferencesWindowBuffer + off, PREFERENCES_WINDOW_WIDTH);
}
blitBufferToBufferTrans(gPreferencesWindowFrmData[PREFERENCES_WINDOW_FRM_KNOB_ON], 21, 12, 21, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + v31, PREFERENCES_WINDOW_WIDTH);
blitBufferToBufferTrans(_preferencesFrmImages[PREFERENCES_WINDOW_FRM_KNOB_ON].getData(), 21, 12, 21, gPreferencesWindowBuffer + PREFERENCES_WINDOW_WIDTH * meta->knobY + v31, PREFERENCES_WINDOW_WIDTH);
windowRefresh(gPreferencesWindow);
while (getTicksSince(tick) < 35)