mirror of
https://github.com/alexbatalov/fallout1-ce.git
synced 2024-10-02 21:02:03 +00:00
Improve button functions readability
This commit is contained in:
parent
46b8d4d467
commit
c1d244e1e5
@ -10,16 +10,19 @@
|
|||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
|
// The maximum number of button groups.
|
||||||
|
#define BUTTON_GROUP_LIST_CAPACITY 64
|
||||||
|
|
||||||
// 0x53A258
|
// 0x53A258
|
||||||
static int last_button_winID = -1;
|
static int last_button_winID = -1;
|
||||||
|
|
||||||
// 0x6AC2D0
|
// 0x6AC2D0
|
||||||
static RadioGroup btn_grp[RADIO_GROUP_LIST_CAPACITY];
|
static ButtonGroup btn_grp[BUTTON_GROUP_LIST_CAPACITY];
|
||||||
|
|
||||||
static Button* button_create(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, int flags, unsigned char* up, unsigned char* dn, unsigned char* hover);
|
static Button* button_create(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, int flags, unsigned char* up, unsigned char* dn, unsigned char* hover);
|
||||||
static bool button_under_mouse(Button* button, Rect* rect);
|
static bool button_under_mouse(Button* button, Rect* rect);
|
||||||
static int button_check_group(Button* button);
|
static int button_check_group(Button* button);
|
||||||
static void button_draw(Button* button, Window* window, unsigned char* data, int a4, Rect* a5, int a6);
|
static void button_draw(Button* button, Window* window, unsigned char* data, bool draw, Rect* bound, bool sound);
|
||||||
|
|
||||||
// 0x4C4320
|
// 0x4C4320
|
||||||
int win_register_button(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, unsigned char* up, unsigned char* dn, unsigned char* hover, int flags)
|
int win_register_button(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, unsigned char* up, unsigned char* dn, unsigned char* hover, int flags)
|
||||||
@ -38,12 +41,12 @@ int win_register_button(int win, int x, int y, int width, int height, int mouseE
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button* button = button_create(win, x, y, width, height, mouseEnterEventCode, mouseExitEventCode, mouseDownEventCode, mouseUpEventCode, flags | BUTTON_FLAG_0x010000, up, dn, hover);
|
Button* button = button_create(win, x, y, width, height, mouseEnterEventCode, mouseExitEventCode, mouseDownEventCode, mouseUpEventCode, flags | BUTTON_FLAG_GRAPHIC, up, dn, hover);
|
||||||
if (button == NULL) {
|
if (button == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->normalImage, 0, NULL, 0);
|
button_draw(button, w, button->normalImage, false, NULL, false);
|
||||||
|
|
||||||
return button->id;
|
return button->id;
|
||||||
}
|
}
|
||||||
@ -140,7 +143,7 @@ int win_register_text_button(int win, int x, int y, int mouseEnterEventCode, int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->normalImage, 0, NULL, 0);
|
button_draw(button, w, button->normalImage, false, NULL, false);
|
||||||
|
|
||||||
return button->id;
|
return button->id;
|
||||||
}
|
}
|
||||||
@ -165,7 +168,7 @@ int win_register_button_disable(int btn, unsigned char* up, unsigned char* down,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C4768
|
// 0x4C4768
|
||||||
int win_register_button_image(int btn, unsigned char* up, unsigned char* down, unsigned char* hover, int a5)
|
int win_register_button_image(int btn, unsigned char* up, unsigned char* down, unsigned char* hover, bool draw)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -181,7 +184,7 @@ int win_register_button_image(int btn, unsigned char* up, unsigned char* down, u
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(button->flags & BUTTON_FLAG_0x010000)) {
|
if ((button->flags & BUTTON_FLAG_GRAPHIC) == 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +201,7 @@ int win_register_button_image(int btn, unsigned char* up, unsigned char* down, u
|
|||||||
button->pressedImage = down;
|
button->pressedImage = down;
|
||||||
button->hoverImage = hover;
|
button->hoverImage = hover;
|
||||||
|
|
||||||
button_draw(button, w, button->currentImage, a5, NULL, 0);
|
button_draw(button, w, button->currentImage, draw, NULL, false);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -250,7 +253,7 @@ int win_register_right_button(int btn, int rightMouseDownEventCode, int rightMou
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C48B0
|
// 0x4C48B0
|
||||||
int win_register_button_sound_func(int btn, ButtonCallback* onPressed, ButtonCallback* onUnpressed)
|
int win_register_button_sound_func(int btn, ButtonCallback* pressSoundFunc, ButtonCallback* releaseSoundFunc)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -261,8 +264,8 @@ int win_register_button_sound_func(int btn, ButtonCallback* onPressed, ButtonCal
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
button->onPressed = onPressed;
|
button->pressSoundFunc = pressSoundFunc;
|
||||||
button->onUnpressed = onUnpressed;
|
button->releaseSoundFunc = releaseSoundFunc;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -336,9 +339,9 @@ static Button* button_create(int win, int x, int y, int width, int height, int m
|
|||||||
button->leftMouseUpProc = NULL;
|
button->leftMouseUpProc = NULL;
|
||||||
button->rightMouseDownProc = NULL;
|
button->rightMouseDownProc = NULL;
|
||||||
button->rightMouseUpProc = NULL;
|
button->rightMouseUpProc = NULL;
|
||||||
button->onPressed = NULL;
|
button->pressSoundFunc = NULL;
|
||||||
button->onUnpressed = NULL;
|
button->releaseSoundFunc = NULL;
|
||||||
button->radioGroup = NULL;
|
button->buttonGroup = NULL;
|
||||||
button->prev = NULL;
|
button->prev = NULL;
|
||||||
|
|
||||||
button->next = w->buttonListHead;
|
button->next = w->buttonListHead;
|
||||||
@ -362,7 +365,7 @@ bool win_button_down(int btn)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x01) != 0 && (button->flags & BUTTON_FLAG_0x020000) != 0) {
|
if ((button->flags & BUTTON_FLAG_0x01) != 0 && (button->flags & BUTTON_FLAG_CHECKED) != 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -373,8 +376,8 @@ bool win_button_down(int btn)
|
|||||||
int GNW_check_buttons(Window* w, int* keyCodePtr)
|
int GNW_check_buttons(Window* w, int* keyCodePtr)
|
||||||
{
|
{
|
||||||
Rect v58;
|
Rect v58;
|
||||||
Button* field_34;
|
Button* hoveredButton;
|
||||||
Button* field_38;
|
Button* clickedButton;
|
||||||
Button* button;
|
Button* button;
|
||||||
|
|
||||||
if ((w->flags & WINDOW_HIDDEN) != 0) {
|
if ((w->flags & WINDOW_HIDDEN) != 0) {
|
||||||
@ -382,14 +385,14 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
button = w->buttonListHead;
|
button = w->buttonListHead;
|
||||||
field_34 = w->hoveredButton;
|
hoveredButton = w->hoveredButton;
|
||||||
field_38 = w->clickedButton;
|
clickedButton = w->clickedButton;
|
||||||
|
|
||||||
if (field_34 != NULL) {
|
if (hoveredButton != NULL) {
|
||||||
rectCopy(&v58, &(field_34->rect));
|
rectCopy(&v58, &(hoveredButton->rect));
|
||||||
rectOffset(&v58, w->rect.ulx, w->rect.uly);
|
rectOffset(&v58, w->rect.ulx, w->rect.uly);
|
||||||
} else if (field_38 != NULL) {
|
} else if (clickedButton != NULL) {
|
||||||
rectCopy(&v58, &(field_38->rect));
|
rectCopy(&v58, &(clickedButton->rect));
|
||||||
rectOffset(&v58, w->rect.ulx, w->rect.uly);
|
rectOffset(&v58, w->rect.ulx, w->rect.uly);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -405,53 +408,53 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
win_show(w->id);
|
win_show(w->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_34 != NULL) {
|
if (hoveredButton != NULL) {
|
||||||
if (!button_under_mouse(field_34, &v58)) {
|
if (!button_under_mouse(hoveredButton, &v58)) {
|
||||||
if (!(field_34->flags & BUTTON_FLAG_DISABLED)) {
|
if (!(hoveredButton->flags & BUTTON_FLAG_DISABLED)) {
|
||||||
*keyCodePtr = field_34->mouseExitEventCode;
|
*keyCodePtr = hoveredButton->mouseExitEventCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((field_34->flags & BUTTON_FLAG_0x01) && (field_34->flags & BUTTON_FLAG_0x020000)) {
|
if ((hoveredButton->flags & BUTTON_FLAG_0x01) && (hoveredButton->flags & BUTTON_FLAG_CHECKED)) {
|
||||||
button_draw(field_34, w, field_34->pressedImage, 1, NULL, 1);
|
button_draw(hoveredButton, w, hoveredButton->pressedImage, true, NULL, true);
|
||||||
} else {
|
} else {
|
||||||
button_draw(field_34, w, field_34->normalImage, 1, NULL, 1);
|
button_draw(hoveredButton, w, hoveredButton->normalImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->hoveredButton = NULL;
|
w->hoveredButton = NULL;
|
||||||
|
|
||||||
last_button_winID = w->id;
|
last_button_winID = w->id;
|
||||||
|
|
||||||
if (!(field_34->flags & BUTTON_FLAG_DISABLED)) {
|
if (!(hoveredButton->flags & BUTTON_FLAG_DISABLED)) {
|
||||||
if (field_34->mouseExitProc != NULL) {
|
if (hoveredButton->mouseExitProc != NULL) {
|
||||||
field_34->mouseExitProc(field_34->id, *keyCodePtr);
|
hoveredButton->mouseExitProc(hoveredButton->id, *keyCodePtr);
|
||||||
if (!(field_34->flags & BUTTON_FLAG_0x40)) {
|
if (!(hoveredButton->flags & BUTTON_FLAG_0x40)) {
|
||||||
*keyCodePtr = -1;
|
*keyCodePtr = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
button = field_34;
|
button = hoveredButton;
|
||||||
} else if (field_38 != NULL) {
|
} else if (clickedButton != NULL) {
|
||||||
if (button_under_mouse(field_38, &v58)) {
|
if (button_under_mouse(clickedButton, &v58)) {
|
||||||
if (!(field_38->flags & BUTTON_FLAG_DISABLED)) {
|
if (!(clickedButton->flags & BUTTON_FLAG_DISABLED)) {
|
||||||
*keyCodePtr = field_38->mouseEnterEventCode;
|
*keyCodePtr = clickedButton->mouseEnterEventCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((field_38->flags & BUTTON_FLAG_0x01) && (field_38->flags & BUTTON_FLAG_0x020000)) {
|
if ((clickedButton->flags & BUTTON_FLAG_0x01) && (clickedButton->flags & BUTTON_FLAG_CHECKED)) {
|
||||||
button_draw(field_38, w, field_38->pressedImage, 1, NULL, 1);
|
button_draw(clickedButton, w, clickedButton->pressedImage, true, NULL, true);
|
||||||
} else {
|
} else {
|
||||||
button_draw(field_38, w, field_38->normalImage, 1, NULL, 1);
|
button_draw(clickedButton, w, clickedButton->normalImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
w->hoveredButton = field_38;
|
w->hoveredButton = clickedButton;
|
||||||
|
|
||||||
last_button_winID = w->id;
|
last_button_winID = w->id;
|
||||||
|
|
||||||
if (!(field_38->flags & BUTTON_FLAG_DISABLED)) {
|
if (!(clickedButton->flags & BUTTON_FLAG_DISABLED)) {
|
||||||
if (field_38->mouseEnterProc != NULL) {
|
if (clickedButton->mouseEnterProc != NULL) {
|
||||||
field_38->mouseEnterProc(field_38->id, *keyCodePtr);
|
clickedButton->mouseEnterProc(clickedButton->id, *keyCodePtr);
|
||||||
if (!(field_38->flags & BUTTON_FLAG_0x40)) {
|
if (!(clickedButton->flags & BUTTON_FLAG_0x40)) {
|
||||||
*keyCodePtr = -1;
|
*keyCodePtr = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -472,10 +475,10 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
*keyCodePtr = v28->mouseExitEventCode;
|
*keyCodePtr = v28->mouseExitEventCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((v28->flags & BUTTON_FLAG_0x01) && (v28->flags & BUTTON_FLAG_0x020000)) {
|
if ((v28->flags & BUTTON_FLAG_0x01) && (v28->flags & BUTTON_FLAG_CHECKED)) {
|
||||||
button_draw(v28, v26, v28->pressedImage, 1, NULL, 1);
|
button_draw(v28, v26, v28->pressedImage, true, NULL, true);
|
||||||
} else {
|
} else {
|
||||||
button_draw(v28, v26, v28->normalImage, 1, NULL, 1);
|
button_draw(v28, v26, v28->normalImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
v26->clickedButton = NULL;
|
v26->clickedButton = NULL;
|
||||||
@ -517,10 +520,10 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x01) != 0) {
|
if ((button->flags & BUTTON_FLAG_0x01) != 0) {
|
||||||
if ((button->flags & BUTTON_FLAG_0x02) != 0) {
|
if ((button->flags & BUTTON_FLAG_0x02) != 0) {
|
||||||
if ((button->flags & BUTTON_FLAG_0x020000) != 0) {
|
if ((button->flags & BUTTON_FLAG_CHECKED) != 0) {
|
||||||
if (!(button->flags & BUTTON_FLAG_0x04)) {
|
if (!(button->flags & BUTTON_FLAG_0x04)) {
|
||||||
if (button->radioGroup != NULL) {
|
if (button->buttonGroup != NULL) {
|
||||||
button->radioGroup->field_4--;
|
button->buttonGroup->currChecked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mouseEvent & MOUSE_EVENT_LEFT_BUTTON_DOWN) != 0) {
|
if ((mouseEvent & MOUSE_EVENT_LEFT_BUTTON_DOWN) != 0) {
|
||||||
@ -531,7 +534,7 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
cb = button->rightMouseUpProc;
|
cb = button->rightMouseUpProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
button->flags &= ~BUTTON_FLAG_0x020000;
|
button->flags &= ~BUTTON_FLAG_CHECKED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button_check_group(button) == -1) {
|
if (button_check_group(button) == -1) {
|
||||||
@ -547,7 +550,7 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
cb = button->rightMouseDownProc;
|
cb = button->rightMouseDownProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
button->flags |= BUTTON_FLAG_0x020000;
|
button->flags |= BUTTON_FLAG_CHECKED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -565,7 +568,7 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->pressedImage, 1, NULL, 1);
|
button_draw(button, w, button->pressedImage, true, NULL, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,10 +579,10 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
|
|
||||||
if (v49->flags & BUTTON_FLAG_0x01) {
|
if (v49->flags & BUTTON_FLAG_0x01) {
|
||||||
if (!(v49->flags & BUTTON_FLAG_0x02)) {
|
if (!(v49->flags & BUTTON_FLAG_0x02)) {
|
||||||
if (v49->flags & BUTTON_FLAG_0x020000) {
|
if (v49->flags & BUTTON_FLAG_CHECKED) {
|
||||||
if (!(v49->flags & BUTTON_FLAG_0x04)) {
|
if (!(v49->flags & BUTTON_FLAG_0x04)) {
|
||||||
if (v49->radioGroup != NULL) {
|
if (v49->buttonGroup != NULL) {
|
||||||
v49->radioGroup->field_4--;
|
v49->buttonGroup->currChecked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mouseEvent & MOUSE_EVENT_LEFT_BUTTON_UP) != 0) {
|
if ((mouseEvent & MOUSE_EVENT_LEFT_BUTTON_UP) != 0) {
|
||||||
@ -590,12 +593,12 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
cb = button->rightMouseUpProc;
|
cb = button->rightMouseUpProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
button->flags &= ~BUTTON_FLAG_0x020000;
|
button->flags &= ~BUTTON_FLAG_CHECKED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (button_check_group(v49) == -1) {
|
if (button_check_group(v49) == -1) {
|
||||||
button = NULL;
|
button = NULL;
|
||||||
button_draw(v49, w, v49->normalImage, 1, NULL, 1);
|
button_draw(v49, w, v49->normalImage, true, NULL, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,13 +610,13 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
cb = v49->rightMouseDownProc;
|
cb = v49->rightMouseDownProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
v49->flags |= BUTTON_FLAG_0x020000;
|
v49->flags |= BUTTON_FLAG_CHECKED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (v49->flags & BUTTON_FLAG_0x020000) {
|
if (v49->flags & BUTTON_FLAG_CHECKED) {
|
||||||
if (v49->radioGroup != NULL) {
|
if (v49->buttonGroup != NULL) {
|
||||||
v49->radioGroup->field_4--;
|
v49->buttonGroup->currChecked--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -627,9 +630,9 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (button->hoverImage != NULL) {
|
if (button->hoverImage != NULL) {
|
||||||
button_draw(button, w, button->hoverImage, 1, NULL, 1);
|
button_draw(button, w, button->hoverImage, true, NULL, true);
|
||||||
} else {
|
} else {
|
||||||
button_draw(button, w, button->normalImage, 1, NULL, 1);
|
button_draw(button, w, button->normalImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -642,7 +645,7 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
cb = button->mouseEnterProc;
|
cb = button->mouseEnterProc;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->hoverImage, 1, NULL, 1);
|
button_draw(button, w, button->hoverImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -655,7 +658,7 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
&& (mouseEvent & MOUSE_EVENT_ANY_BUTTON_DOWN) != 0
|
&& (mouseEvent & MOUSE_EVENT_ANY_BUTTON_DOWN) != 0
|
||||||
&& (mouseEvent & MOUSE_EVENT_ANY_BUTTON_REPEAT) == 0) {
|
&& (mouseEvent & MOUSE_EVENT_ANY_BUTTON_REPEAT) == 0) {
|
||||||
win_drag(w->id);
|
win_drag(w->id);
|
||||||
button_draw(button, w, button->normalImage, 1, NULL, 1);
|
button_draw(button, w, button->normalImage, true, NULL, true);
|
||||||
}
|
}
|
||||||
} else if ((w->flags & WINDOW_FLAG_0x80) != 0) {
|
} else if ((w->flags & WINDOW_FLAG_0x80) != 0) {
|
||||||
v25 |= mouseEvent << 8;
|
v25 |= mouseEvent << 8;
|
||||||
@ -679,17 +682,17 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_34 != NULL) {
|
if (hoveredButton != NULL) {
|
||||||
*keyCodePtr = field_34->mouseExitEventCode;
|
*keyCodePtr = hoveredButton->mouseExitEventCode;
|
||||||
|
|
||||||
unsigned char* data;
|
unsigned char* data;
|
||||||
if ((field_34->flags & BUTTON_FLAG_0x01) && (field_34->flags & BUTTON_FLAG_0x020000)) {
|
if ((hoveredButton->flags & BUTTON_FLAG_0x01) && (hoveredButton->flags & BUTTON_FLAG_CHECKED)) {
|
||||||
data = field_34->pressedImage;
|
data = hoveredButton->pressedImage;
|
||||||
} else {
|
} else {
|
||||||
data = field_34->normalImage;
|
data = hoveredButton->normalImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(field_34, w, data, 1, NULL, 1);
|
button_draw(hoveredButton, w, data, true, NULL, true);
|
||||||
|
|
||||||
w->hoveredButton = NULL;
|
w->hoveredButton = NULL;
|
||||||
}
|
}
|
||||||
@ -697,10 +700,10 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
if (*keyCodePtr != -1) {
|
if (*keyCodePtr != -1) {
|
||||||
last_button_winID = w->id;
|
last_button_winID = w->id;
|
||||||
|
|
||||||
if ((field_34->flags & BUTTON_FLAG_DISABLED) == 0) {
|
if ((hoveredButton->flags & BUTTON_FLAG_DISABLED) == 0) {
|
||||||
if (field_34->mouseExitProc != NULL) {
|
if (hoveredButton->mouseExitProc != NULL) {
|
||||||
field_34->mouseExitProc(field_34->id, *keyCodePtr);
|
hoveredButton->mouseExitProc(hoveredButton->id, *keyCodePtr);
|
||||||
if (!(field_34->flags & BUTTON_FLAG_0x40)) {
|
if (!(hoveredButton->flags & BUTTON_FLAG_0x40)) {
|
||||||
*keyCodePtr = -1;
|
*keyCodePtr = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -708,10 +711,10 @@ int GNW_check_buttons(Window* w, int* keyCodePtr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (field_34 != NULL) {
|
if (hoveredButton != NULL) {
|
||||||
if ((field_34->flags & BUTTON_FLAG_DISABLED) == 0) {
|
if ((hoveredButton->flags & BUTTON_FLAG_DISABLED) == 0) {
|
||||||
if (field_34->mouseExitProc != NULL) {
|
if (hoveredButton->mouseExitProc != NULL) {
|
||||||
field_34->mouseExitProc(field_34->id, *keyCodePtr);
|
hoveredButton->mouseExitProc(hoveredButton->id, *keyCodePtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -802,7 +805,7 @@ int win_delete_button(int btn)
|
|||||||
// 0x4C542C
|
// 0x4C542C
|
||||||
void GNW_delete_button(Button* button)
|
void GNW_delete_button(Button* button)
|
||||||
{
|
{
|
||||||
if ((button->flags & BUTTON_FLAG_0x010000) == 0) {
|
if ((button->flags & BUTTON_FLAG_GRAPHIC) == 0) {
|
||||||
if (button->normalImage != NULL) {
|
if (button->normalImage != NULL) {
|
||||||
mem_free(button->normalImage);
|
mem_free(button->normalImage);
|
||||||
}
|
}
|
||||||
@ -828,15 +831,15 @@ void GNW_delete_button(Button* button)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RadioGroup* radioGroup = button->radioGroup;
|
ButtonGroup* buttonGroup = button->buttonGroup;
|
||||||
if (radioGroup != NULL) {
|
if (buttonGroup != NULL) {
|
||||||
for (int index = 0; index < radioGroup->buttonsLength; index++) {
|
for (int index = 0; index < buttonGroup->buttonsLength; index++) {
|
||||||
if (button == radioGroup->buttons[index]) {
|
if (button == buttonGroup->buttons[index]) {
|
||||||
for (; index < radioGroup->buttonsLength - 1; index++) {
|
for (; index < buttonGroup->buttonsLength - 1; index++) {
|
||||||
radioGroup->buttons[index] = radioGroup->buttons[index + 1];
|
buttonGroup->buttons[index] = buttonGroup->buttons[index + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
radioGroup->buttonsLength--;
|
buttonGroup->buttonsLength--;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -887,7 +890,7 @@ int win_enable_button(int btn)
|
|||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_DISABLED) != 0) {
|
if ((button->flags & BUTTON_FLAG_DISABLED) != 0) {
|
||||||
button->flags &= ~BUTTON_FLAG_DISABLED;
|
button->flags &= ~BUTTON_FLAG_DISABLED;
|
||||||
button_draw(button, w, button->currentImage, 1, NULL, 0);
|
button_draw(button, w, button->currentImage, true, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -909,7 +912,7 @@ int win_disable_button(int btn)
|
|||||||
if ((button->flags & BUTTON_FLAG_DISABLED) == 0) {
|
if ((button->flags & BUTTON_FLAG_DISABLED) == 0) {
|
||||||
button->flags |= BUTTON_FLAG_DISABLED;
|
button->flags |= BUTTON_FLAG_DISABLED;
|
||||||
|
|
||||||
button_draw(button, w, button->currentImage, 1, NULL, 0);
|
button_draw(button, w, button->currentImage, true, NULL, false);
|
||||||
|
|
||||||
if (button == w->hoveredButton) {
|
if (button == w->hoveredButton) {
|
||||||
if (w->hoveredButton->mouseExitEventCode != -1) {
|
if (w->hoveredButton->mouseExitEventCode != -1) {
|
||||||
@ -923,7 +926,7 @@ int win_disable_button(int btn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C560C
|
// 0x4C560C
|
||||||
int win_set_button_rest_state(int btn, bool a2, int a3)
|
int win_set_button_rest_state(int btn, bool checked, int flags)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -938,30 +941,30 @@ int win_set_button_rest_state(int btn, bool a2, int a3)
|
|||||||
if ((button->flags & BUTTON_FLAG_0x01) != 0) {
|
if ((button->flags & BUTTON_FLAG_0x01) != 0) {
|
||||||
int keyCode = -1;
|
int keyCode = -1;
|
||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x020000) != 0) {
|
if ((button->flags & BUTTON_FLAG_CHECKED) != 0) {
|
||||||
if (!a2) {
|
if (!checked) {
|
||||||
button->flags &= ~BUTTON_FLAG_0x020000;
|
button->flags &= ~BUTTON_FLAG_CHECKED;
|
||||||
|
|
||||||
if ((a3 & 0x02) == 0) {
|
if ((flags & 0x02) == 0) {
|
||||||
button_draw(button, w, button->normalImage, 1, NULL, 0);
|
button_draw(button, w, button->normalImage, true, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->radioGroup != NULL) {
|
if (button->buttonGroup != NULL) {
|
||||||
button->radioGroup->field_4--;
|
button->buttonGroup->currChecked--;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCode = button->leftMouseUpEventCode;
|
keyCode = button->leftMouseUpEventCode;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (a2) {
|
if (checked) {
|
||||||
button->flags |= BUTTON_FLAG_0x020000;
|
button->flags |= BUTTON_FLAG_CHECKED;
|
||||||
|
|
||||||
if ((a3 & 0x02) == 0) {
|
if ((flags & 0x02) == 0) {
|
||||||
button_draw(button, w, button->pressedImage, 1, NULL, 0);
|
button_draw(button, w, button->pressedImage, true, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->radioGroup != NULL) {
|
if (button->buttonGroup != NULL) {
|
||||||
button->radioGroup->field_4++;
|
button->buttonGroup->currChecked++;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCode = button->lefMouseDownEventCode;
|
keyCode = button->lefMouseDownEventCode;
|
||||||
@ -969,7 +972,7 @@ int win_set_button_rest_state(int btn, bool a2, int a3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode != -1) {
|
if (keyCode != -1) {
|
||||||
if ((a3 & 0x01) != 0) {
|
if ((flags & 0x01) != 0) {
|
||||||
GNW_add_input_buffer(keyCode);
|
GNW_add_input_buffer(keyCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -979,20 +982,20 @@ int win_set_button_rest_state(int btn, bool a2, int a3)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C56E4
|
// 0x4C56E4
|
||||||
int win_group_check_buttons(int buttonCount, int* btns, int a3, void (*a4)(int))
|
int win_group_check_buttons(int buttonCount, int* btns, int maxChecked, RadioButtonCallback* func)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (buttonCount >= RADIO_GROUP_BUTTON_LIST_CAPACITY) {
|
if (buttonCount >= BUTTON_GROUP_BUTTON_LIST_CAPACITY) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int groupIndex = 0; groupIndex < RADIO_GROUP_LIST_CAPACITY; groupIndex++) {
|
for (int groupIndex = 0; groupIndex < BUTTON_GROUP_LIST_CAPACITY; groupIndex++) {
|
||||||
RadioGroup* radioGroup = &(btn_grp[groupIndex]);
|
ButtonGroup* buttonGroup = &(btn_grp[groupIndex]);
|
||||||
if (radioGroup->buttonsLength == 0) {
|
if (buttonGroup->buttonsLength == 0) {
|
||||||
radioGroup->field_4 = 0;
|
buttonGroup->currChecked = 0;
|
||||||
|
|
||||||
for (int buttonIndex = 0; buttonIndex < buttonCount; buttonIndex++) {
|
for (int buttonIndex = 0; buttonIndex < buttonCount; buttonIndex++) {
|
||||||
Button* button = GNW_find_button(btns[buttonIndex], NULL);
|
Button* button = GNW_find_button(btns[buttonIndex], NULL);
|
||||||
@ -1000,18 +1003,18 @@ int win_group_check_buttons(int buttonCount, int* btns, int a3, void (*a4)(int))
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
radioGroup->buttons[buttonIndex] = button;
|
buttonGroup->buttons[buttonIndex] = button;
|
||||||
|
|
||||||
button->radioGroup = radioGroup;
|
button->buttonGroup = buttonGroup;
|
||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x020000) != 0) {
|
if ((button->flags & BUTTON_FLAG_CHECKED) != 0) {
|
||||||
radioGroup->field_4++;
|
buttonGroup->currChecked++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
radioGroup->buttonsLength = buttonCount;
|
buttonGroup->buttonsLength = buttonCount;
|
||||||
radioGroup->field_0 = a3;
|
buttonGroup->maxChecked = maxChecked;
|
||||||
radioGroup->field_8 = a4;
|
buttonGroup->func = func;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,22 +1023,22 @@ int win_group_check_buttons(int buttonCount, int* btns, int a3, void (*a4)(int))
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C57A4
|
// 0x4C57A4
|
||||||
int win_group_radio_buttons(int count, int* btns)
|
int win_group_radio_buttons(int buttonCount, int* btns)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (win_group_check_buttons(count, btns, 1, NULL) == -1) {
|
if (win_group_check_buttons(buttonCount, btns, 1, NULL) == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Button* button = GNW_find_button(btns[0], NULL);
|
Button* button = GNW_find_button(btns[0], NULL);
|
||||||
RadioGroup* radioGroup = button->radioGroup;
|
ButtonGroup* buttonGroup = button->buttonGroup;
|
||||||
|
|
||||||
for (int index = 0; index < radioGroup->buttonsLength; index++) {
|
for (int index = 0; index < buttonGroup->buttonsLength; index++) {
|
||||||
Button* v1 = radioGroup->buttons[index];
|
Button* v1 = buttonGroup->buttons[index];
|
||||||
v1->flags |= BUTTON_FLAG_0x040000;
|
v1->flags |= BUTTON_FLAG_RADIO;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1044,52 +1047,52 @@ int win_group_radio_buttons(int count, int* btns)
|
|||||||
// 0x4C57FC
|
// 0x4C57FC
|
||||||
static int button_check_group(Button* button)
|
static int button_check_group(Button* button)
|
||||||
{
|
{
|
||||||
if (button->radioGroup == NULL) {
|
if (button->buttonGroup == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x040000) != 0) {
|
if ((button->flags & BUTTON_FLAG_RADIO) != 0) {
|
||||||
if (button->radioGroup->field_4 > 0) {
|
if (button->buttonGroup->currChecked > 0) {
|
||||||
for (int index = 0; index < button->radioGroup->buttonsLength; index++) {
|
for (int index = 0; index < button->buttonGroup->buttonsLength; index++) {
|
||||||
Button* v1 = button->radioGroup->buttons[index];
|
Button* otherButton = button->buttonGroup->buttons[index];
|
||||||
if ((v1->flags & BUTTON_FLAG_0x020000) != 0) {
|
if ((otherButton->flags & BUTTON_FLAG_CHECKED) != 0) {
|
||||||
v1->flags &= ~BUTTON_FLAG_0x020000;
|
otherButton->flags &= ~BUTTON_FLAG_CHECKED;
|
||||||
|
|
||||||
Window* w;
|
Window* w;
|
||||||
GNW_find_button(v1->id, &w);
|
GNW_find_button(otherButton->id, &w);
|
||||||
button_draw(v1, w, v1->normalImage, 1, NULL, 1);
|
button_draw(otherButton, w, otherButton->normalImage, true, NULL, true);
|
||||||
|
|
||||||
if (v1->leftMouseUpProc != NULL) {
|
if (otherButton->leftMouseUpProc != NULL) {
|
||||||
v1->leftMouseUpProc(v1->id, v1->leftMouseUpEventCode);
|
otherButton->leftMouseUpProc(otherButton->id, otherButton->leftMouseUpEventCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((button->flags & BUTTON_FLAG_0x020000) == 0) {
|
if ((button->flags & BUTTON_FLAG_CHECKED) == 0) {
|
||||||
button->radioGroup->field_4++;
|
button->buttonGroup->currChecked++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->radioGroup->field_4 < button->radioGroup->field_0) {
|
if (button->buttonGroup->currChecked < button->buttonGroup->maxChecked) {
|
||||||
if ((button->flags & BUTTON_FLAG_0x020000) == 0) {
|
if ((button->flags & BUTTON_FLAG_CHECKED) == 0) {
|
||||||
button->radioGroup->field_4++;
|
button->buttonGroup->currChecked++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (button->radioGroup->field_8 != NULL) {
|
if (button->buttonGroup->func != NULL) {
|
||||||
button->radioGroup->field_8(button->id);
|
button->buttonGroup->func(button->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C58C0
|
// 0x4C58C0
|
||||||
static void button_draw(Button* button, Window* w, unsigned char* data, int a4, Rect* a5, int a6)
|
static void button_draw(Button* button, Window* w, unsigned char* data, bool draw, Rect* bound, bool sound)
|
||||||
{
|
{
|
||||||
unsigned char* previousImage = NULL;
|
unsigned char* previousImage = NULL;
|
||||||
if (data != NULL) {
|
if (data != NULL) {
|
||||||
@ -1098,8 +1101,8 @@ static void button_draw(Button* button, Window* w, unsigned char* data, int a4,
|
|||||||
rectOffset(&v2, w->rect.ulx, w->rect.uly);
|
rectOffset(&v2, w->rect.ulx, w->rect.uly);
|
||||||
|
|
||||||
Rect v3;
|
Rect v3;
|
||||||
if (a5 != NULL) {
|
if (bound != NULL) {
|
||||||
if (rect_inside_bound(&v2, a5, &v2) == -1) {
|
if (rect_inside_bound(&v2, bound, &v2) == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1109,7 +1112,7 @@ static void button_draw(Button* button, Window* w, unsigned char* data, int a4,
|
|||||||
rectCopy(&v3, &(button->rect));
|
rectCopy(&v3, &(button->rect));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == button->normalImage && (button->flags & BUTTON_FLAG_0x020000)) {
|
if (data == button->normalImage && (button->flags & BUTTON_FLAG_CHECKED)) {
|
||||||
data = button->pressedImage;
|
data = button->pressedImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1132,7 +1135,7 @@ static void button_draw(Button* button, Window* w, unsigned char* data, int a4,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
if (a4 == 0) {
|
if (!draw) {
|
||||||
int width = button->rect.lrx - button->rect.ulx + 1;
|
int width = button->rect.lrx - button->rect.ulx + 1;
|
||||||
if ((button->flags & BUTTON_FLAG_TRANSPARENT) != 0) {
|
if ((button->flags & BUTTON_FLAG_TRANSPARENT) != 0) {
|
||||||
trans_buf_to_buf(
|
trans_buf_to_buf(
|
||||||
@ -1156,18 +1159,18 @@ static void button_draw(Button* button, Window* w, unsigned char* data, int a4,
|
|||||||
previousImage = button->currentImage;
|
previousImage = button->currentImage;
|
||||||
button->currentImage = data;
|
button->currentImage = data;
|
||||||
|
|
||||||
if (a4 != 0) {
|
if (draw) {
|
||||||
GNW_win_refresh(w, &v2, 0);
|
GNW_win_refresh(w, &v2, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a6) {
|
if (sound) {
|
||||||
if (previousImage != data) {
|
if (previousImage != data) {
|
||||||
if (data == button->pressedImage && button->onPressed != NULL) {
|
if (data == button->pressedImage && button->pressSoundFunc != NULL) {
|
||||||
button->onPressed(button->id, button->lefMouseDownEventCode);
|
button->pressSoundFunc(button->id, button->lefMouseDownEventCode);
|
||||||
} else if (data == button->normalImage && button->onUnpressed != NULL) {
|
} else if (data == button->normalImage && button->releaseSoundFunc != NULL) {
|
||||||
button->onUnpressed(button->id, button->leftMouseUpEventCode);
|
button->releaseSoundFunc(button->id, button->leftMouseUpEventCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1184,7 +1187,7 @@ void GNW_button_refresh(Window* w, Rect* rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (button != NULL) {
|
while (button != NULL) {
|
||||||
button_draw(button, w, button->currentImage, 0, rect, 0);
|
button_draw(button, w, button->currentImage, false, rect, false);
|
||||||
button = button->prev;
|
button = button->prev;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1202,7 +1205,7 @@ int win_button_press_and_release(int btn)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->pressedImage, 1, NULL, 1);
|
button_draw(button, w, button->pressedImage, true, NULL, true);
|
||||||
|
|
||||||
if (button->leftMouseDownProc != NULL) {
|
if (button->leftMouseDownProc != NULL) {
|
||||||
button->leftMouseDownProc(btn, button->lefMouseDownEventCode);
|
button->leftMouseDownProc(btn, button->lefMouseDownEventCode);
|
||||||
@ -1216,7 +1219,7 @@ int win_button_press_and_release(int btn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
button_draw(button, w, button->normalImage, 1, NULL, 1);
|
button_draw(button, w, button->normalImage, true, NULL, true);
|
||||||
|
|
||||||
if (button->leftMouseUpProc != NULL) {
|
if (button->leftMouseUpProc != NULL) {
|
||||||
button->leftMouseUpProc(btn, button->leftMouseUpEventCode);
|
button->leftMouseUpProc(btn, button->leftMouseUpEventCode);
|
||||||
|
@ -8,13 +8,13 @@ namespace fallout {
|
|||||||
int win_register_button(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, unsigned char* up, unsigned char* dn, unsigned char* hover, int flags);
|
int win_register_button(int win, int x, int y, int width, int height, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, unsigned char* up, unsigned char* dn, unsigned char* hover, int flags);
|
||||||
int win_register_text_button(int win, int x, int y, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, const char* title, int flags);
|
int win_register_text_button(int win, int x, int y, int mouseEnterEventCode, int mouseExitEventCode, int mouseDownEventCode, int mouseUpEventCode, const char* title, int flags);
|
||||||
int win_register_button_disable(int btn, unsigned char* up, unsigned char* down, unsigned char* hover);
|
int win_register_button_disable(int btn, unsigned char* up, unsigned char* down, unsigned char* hover);
|
||||||
int win_register_button_image(int btn, unsigned char* up, unsigned char* down, unsigned char* hover, int a5);
|
int win_register_button_image(int btn, unsigned char* up, unsigned char* down, unsigned char* hover, bool draw);
|
||||||
int win_register_button_func(int btn, ButtonCallback* mouseEnterProc, ButtonCallback* mouseExitProc, ButtonCallback* mouseDownProc, ButtonCallback* mouseUpProc);
|
int win_register_button_func(int btn, ButtonCallback* mouseEnterProc, ButtonCallback* mouseExitProc, ButtonCallback* mouseDownProc, ButtonCallback* mouseUpProc);
|
||||||
int win_register_right_button(int btn, int rightMouseDownEventCode, int rightMouseUpEventCode, ButtonCallback* rightMouseDownProc, ButtonCallback* rightMouseUpProc);
|
int win_register_right_button(int btn, int rightMouseDownEventCode, int rightMouseUpEventCode, ButtonCallback* rightMouseDownProc, ButtonCallback* rightMouseUpProc);
|
||||||
int win_register_button_sound_func(int btn, ButtonCallback* onPressed, ButtonCallback* onUnpressed);
|
int win_register_button_sound_func(int btn, ButtonCallback* pressSoundFunc, ButtonCallback* releaseSoundFunc);
|
||||||
int win_register_button_mask(int btn, unsigned char* mask);
|
int win_register_button_mask(int btn, unsigned char* mask);
|
||||||
bool win_button_down(int btn);
|
bool win_button_down(int btn);
|
||||||
int GNW_check_buttons(Window* window, int* out_a2);
|
int GNW_check_buttons(Window* window, int* keyCodePtr);
|
||||||
int win_button_winID(int btn);
|
int win_button_winID(int btn);
|
||||||
int win_last_button_winID();
|
int win_last_button_winID();
|
||||||
int win_delete_button(int btn);
|
int win_delete_button(int btn);
|
||||||
@ -23,9 +23,9 @@ void win_delete_button_win(int btn, int inputEvent);
|
|||||||
int button_new_id();
|
int button_new_id();
|
||||||
int win_enable_button(int btn);
|
int win_enable_button(int btn);
|
||||||
int win_disable_button(int btn);
|
int win_disable_button(int btn);
|
||||||
int win_set_button_rest_state(int btn, bool a2, int a3);
|
int win_set_button_rest_state(int btn, bool checked, int flags);
|
||||||
int win_group_check_buttons(int a1, int* a2, int a3, void (*a4)(int));
|
int win_group_check_buttons(int buttonCount, int* btns, int maxChecked, RadioButtonCallback* func);
|
||||||
int win_group_radio_buttons(int a1, int* a2);
|
int win_group_radio_buttons(int buttonCount, int* btns);
|
||||||
void GNW_button_refresh(Window* window, Rect* rect);
|
void GNW_button_refresh(Window* window, Rect* rect);
|
||||||
int win_button_press_and_release(int btn);
|
int win_button_press_and_release(int btn);
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
|
#define MAX_WINDOW_COUNT 50
|
||||||
|
|
||||||
static void win_free(int win);
|
static void win_free(int win);
|
||||||
static void win_clip(Window* window, RectPtr* rectListNodePtr, unsigned char* a3);
|
static void win_clip(Window* window, RectPtr* rectListNodePtr, unsigned char* a3);
|
||||||
static void refresh_all(Rect* rect, unsigned char* a2);
|
static void refresh_all(Rect* rect, unsigned char* a2);
|
||||||
@ -497,15 +499,12 @@ void win_set_bk_color(int color)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C2908
|
// 0x4C2908
|
||||||
void win_print(int win, const char* str, int a3, int x, int y, int a6)
|
void win_print(int win, const char* str, int width, int x, int y, int color)
|
||||||
{
|
{
|
||||||
int v7;
|
|
||||||
int v14;
|
|
||||||
unsigned char* buf;
|
unsigned char* buf;
|
||||||
int v27;
|
int textColor;
|
||||||
|
|
||||||
Window* w = GNW_find(win);
|
Window* w = GNW_find(win);
|
||||||
v7 = a3;
|
|
||||||
|
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return;
|
return;
|
||||||
@ -515,59 +514,58 @@ void win_print(int win, const char* str, int a3, int x, int y, int a6)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a3 == 0) {
|
if (width == 0) {
|
||||||
if (a6 & 0x040000) {
|
if (color & 0x040000) {
|
||||||
v7 = text_mono_width(str);
|
width = text_mono_width(str);
|
||||||
} else {
|
} else {
|
||||||
v7 = text_width(str);
|
width = text_width(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v7 + x > w->width) {
|
if (width + x > w->width) {
|
||||||
if (!(a6 & 0x04000000)) {
|
if (!(color & 0x04000000)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
v7 = w->width - x;
|
width = w->width - x;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = w->buffer + x + y * w->width;
|
buf = w->buffer + x + y * w->width;
|
||||||
|
|
||||||
v14 = text_height();
|
if (text_height() + y > w->height) {
|
||||||
if (v14 + y > w->height) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(a6 & 0x02000000)) {
|
if (!(color & 0x02000000)) {
|
||||||
if (w->color == 256 && GNW_texture != NULL) {
|
if (w->color == 256 && GNW_texture != NULL) {
|
||||||
buf_texture(buf, v7, text_height(), w->width, GNW_texture, w->tx + x, w->ty + y);
|
buf_texture(buf, width, text_height(), w->width, GNW_texture, w->tx + x, w->ty + y);
|
||||||
} else {
|
} else {
|
||||||
buf_fill(buf, v7, text_height(), w->width, w->color);
|
buf_fill(buf, width, text_height(), w->width, w->color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((a6 & 0xFF00) != 0) {
|
if ((color & 0xFF00) != 0) {
|
||||||
int colorIndex = (a6 & 0xFF) - 1;
|
int colorIndex = (color & 0xFF) - 1;
|
||||||
v27 = (a6 & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
textColor = (color & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
||||||
} else {
|
} else {
|
||||||
v27 = a6;
|
textColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_to_buf(buf, str, v7, w->width, v27);
|
text_to_buf(buf, str, width, w->width, textColor);
|
||||||
|
|
||||||
if (a6 & 0x01000000) {
|
if (color & 0x01000000) {
|
||||||
// TODO: Check.
|
// TODO: Check.
|
||||||
Rect rect;
|
Rect rect;
|
||||||
rect.ulx = w->rect.ulx + x;
|
rect.ulx = w->rect.ulx + x;
|
||||||
rect.uly = w->rect.uly + y;
|
rect.uly = w->rect.uly + y;
|
||||||
rect.lrx = rect.ulx + v7;
|
rect.lrx = rect.ulx + width;
|
||||||
rect.lry = rect.uly + text_height();
|
rect.lry = rect.uly + text_height();
|
||||||
GNW_win_refresh(w, &rect, NULL);
|
GNW_win_refresh(w, &rect, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C2A98
|
// 0x4C2A98
|
||||||
void win_text(int win, char** fileNameList, int fileNameListLength, int maxWidth, int x, int y, int flags)
|
void win_text(int win, char** fileNameList, int fileNameListLength, int maxWidth, int x, int y, int color)
|
||||||
{
|
{
|
||||||
Window* w = GNW_find(win);
|
Window* w = GNW_find(win);
|
||||||
|
|
||||||
@ -591,7 +589,7 @@ void win_text(int win, char** fileNameList, int fileNameListLength, int maxWidth
|
|||||||
for (int index = 0; index < fileNameListLength; index++) {
|
for (int index = 0; index < fileNameListLength; index++) {
|
||||||
char* fileName = fileNameList[index];
|
char* fileName = fileNameList[index];
|
||||||
if (*fileName != '\0') {
|
if (*fileName != '\0') {
|
||||||
win_print(win, fileName, maxWidth, x, y, flags);
|
win_print(win, fileName, maxWidth, x, y, color);
|
||||||
} else {
|
} else {
|
||||||
if (maxWidth != 0) {
|
if (maxWidth != 0) {
|
||||||
draw_line(ptr, width, 0, v1, v3, v1, colorTable[GNW_wcolor[2]]);
|
draw_line(ptr, width, 0, v1, v3, v1, colorTable[GNW_wcolor[2]]);
|
||||||
@ -683,7 +681,7 @@ void win_shaded_box(int id, int ulx, int uly, int lrx, int lry, int color1, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C2D84
|
// 0x4C2D84
|
||||||
void win_fill(int win, int x, int y, int width, int height, int a6)
|
void win_fill(int win, int x, int y, int width, int height, int color)
|
||||||
{
|
{
|
||||||
Window* w = GNW_find(win);
|
Window* w = GNW_find(win);
|
||||||
|
|
||||||
@ -695,19 +693,19 @@ void win_fill(int win, int x, int y, int width, int height, int a6)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a6 == 256) {
|
if (color == 256) {
|
||||||
if (GNW_texture != NULL) {
|
if (GNW_texture != NULL) {
|
||||||
buf_texture(w->buffer + w->width * y + x, width, height, w->width, GNW_texture, x + w->tx, y + w->ty);
|
buf_texture(w->buffer + w->width * y + x, width, height, w->width, GNW_texture, x + w->tx, y + w->ty);
|
||||||
} else {
|
} else {
|
||||||
a6 = colorTable[GNW_wcolor[0]] & 0xFF;
|
color = colorTable[GNW_wcolor[0]] & 0xFF;
|
||||||
}
|
}
|
||||||
} else if ((a6 & 0xFF00) != 0) {
|
} else if ((color & 0xFF00) != 0) {
|
||||||
int colorIndex = (a6 & 0xFF) - 1;
|
int colorIndex = (color & 0xFF) - 1;
|
||||||
a6 = (a6 & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
color = (color & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (a6 < 256) {
|
if (color < 256) {
|
||||||
buf_fill(w->buffer + w->width * y + x, width, height, w->width, a6);
|
buf_fill(w->buffer + w->width * y + x, width, height, w->width, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,11 +8,6 @@
|
|||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
#define MAX_WINDOW_COUNT (50)
|
|
||||||
|
|
||||||
// The maximum number of radio groups.
|
|
||||||
#define RADIO_GROUP_LIST_CAPACITY (64)
|
|
||||||
|
|
||||||
typedef enum WindowManagerErr {
|
typedef enum WindowManagerErr {
|
||||||
WINDOW_MANAGER_OK = 0,
|
WINDOW_MANAGER_OK = 0,
|
||||||
WINDOW_MANAGER_ERR_INITIALIZING_VIDEO_MODE = 1,
|
WINDOW_MANAGER_ERR_INITIALIZING_VIDEO_MODE = 1,
|
||||||
@ -45,18 +40,18 @@ extern void* GNW_texture;
|
|||||||
int win_init(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitProc* videoSystemExitProc, int a3);
|
int win_init(VideoSystemInitProc* videoSystemInitProc, VideoSystemExitProc* videoSystemExitProc, int a3);
|
||||||
int win_active();
|
int win_active();
|
||||||
void win_exit(void);
|
void win_exit(void);
|
||||||
int win_add(int x, int y, int width, int height, int a4, int flags);
|
int win_add(int x, int y, int width, int height, int color, int flags);
|
||||||
void win_delete(int win);
|
void win_delete(int win);
|
||||||
void win_buffering(bool a1);
|
void win_buffering(bool a1);
|
||||||
void win_border(int win);
|
void win_border(int win);
|
||||||
void win_no_texture();
|
void win_no_texture();
|
||||||
void win_set_bk_color(int color);
|
void win_set_bk_color(int color);
|
||||||
void win_print(int win, const char* str, int a3, int x, int y, int a6);
|
void win_print(int win, const char* str, int width, int x, int y, int color);
|
||||||
void win_text(int win, char** fileNameList, int fileNameListLength, int maxWidth, int x, int y, int flags);
|
void win_text(int win, char** fileNameList, int fileNameListLength, int maxWidth, int x, int y, int color);
|
||||||
void win_line(int win, int left, int top, int right, int bottom, int color);
|
void win_line(int win, int left, int top, int right, int bottom, int color);
|
||||||
void win_box(int win, int left, int top, int right, int bottom, int color);
|
void win_box(int win, int left, int top, int right, int bottom, int color);
|
||||||
void win_shaded_box(int id, int ulx, int uly, int lrx, int lry, int color1, int color2);
|
void win_shaded_box(int id, int ulx, int uly, int lrx, int lry, int color1, int color2);
|
||||||
void win_fill(int win, int x, int y, int width, int height, int a6);
|
void win_fill(int win, int x, int y, int width, int height, int color);
|
||||||
void win_show(int win);
|
void win_show(int win);
|
||||||
void win_hide(int win);
|
void win_hide(int win);
|
||||||
void win_move(int win_index, int x, int y);
|
void win_move(int win_index, int x, int y);
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
// The maximum number of buttons in one radio group.
|
// The maximum number of buttons in one button group.
|
||||||
#define RADIO_GROUP_BUTTON_LIST_CAPACITY 64
|
#define BUTTON_GROUP_BUTTON_LIST_CAPACITY 64
|
||||||
|
|
||||||
typedef enum WindowFlags {
|
typedef enum WindowFlags {
|
||||||
// Use system window flags which are set during game startup and does not
|
// Use system window flags which are set during game startup and does not
|
||||||
@ -32,25 +32,26 @@ typedef enum ButtonFlags {
|
|||||||
BUTTON_FLAG_0x10 = 0x10,
|
BUTTON_FLAG_0x10 = 0x10,
|
||||||
BUTTON_FLAG_TRANSPARENT = 0x20,
|
BUTTON_FLAG_TRANSPARENT = 0x20,
|
||||||
BUTTON_FLAG_0x40 = 0x40,
|
BUTTON_FLAG_0x40 = 0x40,
|
||||||
BUTTON_FLAG_0x010000 = 0x010000,
|
BUTTON_FLAG_GRAPHIC = 0x010000,
|
||||||
BUTTON_FLAG_0x020000 = 0x020000,
|
BUTTON_FLAG_CHECKED = 0x020000,
|
||||||
BUTTON_FLAG_0x040000 = 0x040000,
|
BUTTON_FLAG_RADIO = 0x040000,
|
||||||
BUTTON_FLAG_RIGHT_MOUSE_BUTTON_CONFIGURED = 0x080000,
|
BUTTON_FLAG_RIGHT_MOUSE_BUTTON_CONFIGURED = 0x080000,
|
||||||
} ButtonFlags;
|
} ButtonFlags;
|
||||||
|
|
||||||
typedef struct Button Button;
|
typedef struct Button Button;
|
||||||
typedef struct RadioGroup RadioGroup;
|
typedef struct ButtonGroup ButtonGroup;
|
||||||
|
|
||||||
typedef void WindowBlitProc(unsigned char* src, int width, int height, int srcPitch, unsigned char* dest, int destPitch);
|
typedef void WindowBlitProc(unsigned char* src, int width, int height, int srcPitch, unsigned char* dest, int destPitch);
|
||||||
typedef void ButtonCallback(int btn, int keyCode);
|
typedef void ButtonCallback(int btn, int keyCode);
|
||||||
|
typedef void RadioButtonCallback(int btn);
|
||||||
|
|
||||||
typedef struct MenuPulldown {
|
typedef struct MenuPulldown {
|
||||||
Rect rect;
|
Rect rect;
|
||||||
int keyCode;
|
int keyCode;
|
||||||
int itemsLength;
|
int itemsLength;
|
||||||
char** items;
|
char** items;
|
||||||
int field_1C;
|
int foregroundColor;
|
||||||
int field_20;
|
int backgroundColor;
|
||||||
} MenuPulldown;
|
} MenuPulldown;
|
||||||
|
|
||||||
typedef struct MenuBar {
|
typedef struct MenuBar {
|
||||||
@ -58,7 +59,7 @@ typedef struct MenuBar {
|
|||||||
Rect rect;
|
Rect rect;
|
||||||
int pulldownsLength;
|
int pulldownsLength;
|
||||||
MenuPulldown pulldowns[15];
|
MenuPulldown pulldowns[15];
|
||||||
int borderColor;
|
int foregroundColor;
|
||||||
int backgroundColor;
|
int backgroundColor;
|
||||||
} MenuBar;
|
} MenuBar;
|
||||||
|
|
||||||
@ -103,20 +104,20 @@ typedef struct Button {
|
|||||||
ButtonCallback* leftMouseUpProc;
|
ButtonCallback* leftMouseUpProc;
|
||||||
ButtonCallback* rightMouseDownProc;
|
ButtonCallback* rightMouseDownProc;
|
||||||
ButtonCallback* rightMouseUpProc;
|
ButtonCallback* rightMouseUpProc;
|
||||||
ButtonCallback* onPressed;
|
ButtonCallback* pressSoundFunc;
|
||||||
ButtonCallback* onUnpressed;
|
ButtonCallback* releaseSoundFunc;
|
||||||
RadioGroup* radioGroup;
|
ButtonGroup* buttonGroup;
|
||||||
Button* prev;
|
Button* prev;
|
||||||
Button* next;
|
Button* next;
|
||||||
} Button;
|
} Button;
|
||||||
|
|
||||||
typedef struct RadioGroup {
|
typedef struct ButtonGroup {
|
||||||
int field_0;
|
int maxChecked;
|
||||||
int field_4;
|
int currChecked;
|
||||||
void (*field_8)(int);
|
RadioButtonCallback* func;
|
||||||
int buttonsLength;
|
int buttonsLength;
|
||||||
Button* buttons[RADIO_GROUP_BUTTON_LIST_CAPACITY];
|
Button* buttons[BUTTON_GROUP_BUTTON_LIST_CAPACITY];
|
||||||
} RadioGroup;
|
} ButtonGroup;
|
||||||
|
|
||||||
} // namespace fallout
|
} // namespace fallout
|
||||||
|
|
||||||
|
@ -16,16 +16,16 @@
|
|||||||
|
|
||||||
namespace fallout {
|
namespace fallout {
|
||||||
|
|
||||||
static int create_pull_down(char** stringList, int stringListLength, int x, int y, int a5, int a6, Rect* rect);
|
static int create_pull_down(char** stringList, int stringListLength, int x, int y, int foregroundColor, int backgroundColor, Rect* rect);
|
||||||
static void win_debug_delete(int btn, int keyCode);
|
static void win_debug_delete(int btn, int keyCode);
|
||||||
static int find_first_letter(int ch, char** stringList, int stringListLength);
|
static int find_first_letter(int ch, char** stringList, int stringListLength);
|
||||||
static int process_pull_down(int win, Rect* rect, char** items, int itemsLength, int a5, int a6, MenuBar* menuBar, int pulldownIndex);
|
static int process_pull_down(int win, Rect* rect, char** items, int itemsLength, int foregroundColor, int backgroundColor, MenuBar* menuBar, int pulldownIndex);
|
||||||
static int calc_max_field_chars_wcursor(int a1, int a2);
|
static int calc_max_field_chars_wcursor(int value1, int value2);
|
||||||
static void tm_watch_msgs();
|
static void tm_watch_msgs();
|
||||||
static void tm_kill_msg();
|
static void tm_kill_msg();
|
||||||
static void tm_kill_out_of_order(int a1);
|
static void tm_kill_out_of_order(int queueIndex);
|
||||||
static void tm_click_response(int btn);
|
static void tm_click_response(int btn);
|
||||||
static int tm_index_active(int a1);
|
static int tm_index_active(int queueIndex);
|
||||||
|
|
||||||
// 0x53A268
|
// 0x53A268
|
||||||
static int wd = -1;
|
static int wd = -1;
|
||||||
@ -68,13 +68,13 @@ static int scr_center_x;
|
|||||||
static int tm_add;
|
static int tm_add;
|
||||||
|
|
||||||
// 0x4C6AA0
|
// 0x4C6AA0
|
||||||
int win_list_select(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int a7)
|
int win_list_select(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int color)
|
||||||
{
|
{
|
||||||
return win_list_select_at(title, fileList, fileListLength, callback, x, y, a7, 0);
|
return win_list_select_at(title, fileList, fileListLength, callback, x, y, color, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C6AEC
|
// 0x4C6AEC
|
||||||
int win_list_select_at(const char* title, char** items, int itemsLength, SelectFunc* callback, int x, int y, int a7, int a8)
|
int win_list_select_at(const char* title, char** items, int itemsLength, SelectFunc* callback, int x, int y, int color, int start)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -159,8 +159,8 @@ int win_list_select_at(const char* title, char** items, int itemsLength, SelectF
|
|||||||
windowWidth,
|
windowWidth,
|
||||||
colorTable[GNW_wcolor[0]]);
|
colorTable[GNW_wcolor[0]]);
|
||||||
|
|
||||||
int scrollOffset = a8;
|
int scrollOffset = start;
|
||||||
if (a8 < 0 || a8 >= itemsLength) {
|
if (start < 0 || start >= itemsLength) {
|
||||||
scrollOffset = 0;
|
scrollOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,14 +178,13 @@ int win_list_select_at(const char* title, char** items, int itemsLength, SelectF
|
|||||||
selectedItemIndex = 0;
|
selectedItemIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char** itemsTO = items + a8;
|
|
||||||
win_text(win,
|
win_text(win,
|
||||||
items + a8,
|
items + start,
|
||||||
itemsLength < listViewCapacity ? itemsLength : listViewCapacity,
|
itemsLength < listViewCapacity ? itemsLength : listViewCapacity,
|
||||||
listViewWidth,
|
listViewWidth,
|
||||||
listViewX,
|
listViewX,
|
||||||
listViewY,
|
listViewY,
|
||||||
a7 | 0x2000000);
|
color | 0x2000000);
|
||||||
|
|
||||||
lighten_buf(listViewBuffer + windowWidth * selectedItemIndex * text_height(),
|
lighten_buf(listViewBuffer + windowWidth * selectedItemIndex * text_height(),
|
||||||
listViewWidth,
|
listViewWidth,
|
||||||
@ -441,7 +440,7 @@ int win_list_select_at(const char* title, char** items, int itemsLength, SelectF
|
|||||||
listViewWidth,
|
listViewWidth,
|
||||||
listViewX,
|
listViewX,
|
||||||
listViewY,
|
listViewY,
|
||||||
a7 | 0x2000000);
|
color | 0x2000000);
|
||||||
|
|
||||||
lighten_buf(listViewBuffer + windowWidth * selectedItemIndex * text_height(),
|
lighten_buf(listViewBuffer + windowWidth * selectedItemIndex * text_height(),
|
||||||
listViewWidth,
|
listViewWidth,
|
||||||
@ -489,19 +488,19 @@ int win_list_select_at(const char* title, char** items, int itemsLength, SelectF
|
|||||||
windowWidth,
|
windowWidth,
|
||||||
colorTable[GNW_wcolor[0]]);
|
colorTable[GNW_wcolor[0]]);
|
||||||
|
|
||||||
int color;
|
int textColor;
|
||||||
if ((a7 & 0xFF00) != 0) {
|
if ((color & 0xFF00) != 0) {
|
||||||
int colorIndex = (a7 & 0xFF) - 1;
|
int colorIndex = (color & 0xFF) - 1;
|
||||||
color = (a7 & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
textColor = (color & ~0xFFFF) | colorTable[GNW_wcolor[colorIndex]];
|
||||||
} else {
|
} else {
|
||||||
color = a7;
|
textColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_to_buf(listViewBuffer + windowWidth * previousSelectedItemIndex * text_height(),
|
text_to_buf(listViewBuffer + windowWidth * previousSelectedItemIndex * text_height(),
|
||||||
items[scrollOffset + previousSelectedItemIndex],
|
items[scrollOffset + previousSelectedItemIndex],
|
||||||
windowWidth,
|
windowWidth,
|
||||||
windowWidth,
|
windowWidth,
|
||||||
color);
|
textColor);
|
||||||
|
|
||||||
GNW_win_refresh(window, &itemRect, NULL);
|
GNW_win_refresh(window, &itemRect, NULL);
|
||||||
}
|
}
|
||||||
@ -608,7 +607,7 @@ int win_get_str(char* dest, int length, const char* title, int x, int y)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C7E78
|
// 0x4C7E78
|
||||||
int win_msg(const char* string, int x, int y, int flags)
|
int win_msg(const char* string, int x, int y, int color)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
@ -633,16 +632,16 @@ int win_msg(const char* string, int x, int y, int flags)
|
|||||||
Window* window = GNW_find(win);
|
Window* window = GNW_find(win);
|
||||||
unsigned char* windowBuffer = window->buffer;
|
unsigned char* windowBuffer = window->buffer;
|
||||||
|
|
||||||
int color;
|
int textColor;
|
||||||
if ((flags & 0xFF00) != 0) {
|
if ((color & 0xFF00) != 0) {
|
||||||
int index = (flags & 0xFF) - 1;
|
int index = (color & 0xFF) - 1;
|
||||||
color = colorTable[GNW_wcolor[index]];
|
textColor = colorTable[GNW_wcolor[index]];
|
||||||
color |= flags & ~0xFFFF;
|
textColor |= color & ~0xFFFF;
|
||||||
} else {
|
} else {
|
||||||
color = flags;
|
textColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
text_to_buf(windowBuffer + windowWidth * 8 + 16, string, windowWidth, windowWidth, color);
|
text_to_buf(windowBuffer + windowWidth * 8 + 16, string, windowWidth, windowWidth, textColor);
|
||||||
|
|
||||||
win_register_text_button(win,
|
win_register_text_button(win,
|
||||||
windowWidth / 2 - 32,
|
windowWidth / 2 - 32,
|
||||||
@ -668,23 +667,23 @@ int win_msg(const char* string, int x, int y, int flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C7FA4
|
// 0x4C7FA4
|
||||||
int win_pull_down(char** items, int itemsLength, int x, int y, int a5)
|
int win_pull_down(char** items, int itemsLength, int x, int y, int color)
|
||||||
{
|
{
|
||||||
if (!GNW_win_init_flag) {
|
if (!GNW_win_init_flag) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect rect;
|
Rect rect;
|
||||||
int win = create_pull_down(items, itemsLength, x, y, a5, colorTable[GNW_wcolor[0]], &rect);
|
int win = create_pull_down(items, itemsLength, x, y, color, colorTable[GNW_wcolor[0]], &rect);
|
||||||
if (win == -1) {
|
if (win == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_pull_down(win, &rect, items, itemsLength, a5, colorTable[GNW_wcolor[0]], NULL, -1);
|
return process_pull_down(win, &rect, items, itemsLength, color, colorTable[GNW_wcolor[0]], NULL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C8014
|
// 0x4C8014
|
||||||
static int create_pull_down(char** stringList, int stringListLength, int x, int y, int a5, int a6, Rect* rect)
|
static int create_pull_down(char** stringList, int stringListLength, int x, int y, int foregroundColor, int backgroundColor, Rect* rect)
|
||||||
{
|
{
|
||||||
int windowHeight = stringListLength * text_height() + 16;
|
int windowHeight = stringListLength * text_height() + 16;
|
||||||
int windowWidth = win_width_needed(stringList, stringListLength) + 4;
|
int windowWidth = win_width_needed(stringList, stringListLength) + 4;
|
||||||
@ -692,14 +691,14 @@ static int create_pull_down(char** stringList, int stringListLength, int x, int
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int win = win_add(x, y, windowWidth, windowHeight, a6, WINDOW_MODAL | WINDOW_MOVE_ON_TOP);
|
int win = win_add(x, y, windowWidth, windowHeight, backgroundColor, WINDOW_MODAL | WINDOW_MOVE_ON_TOP);
|
||||||
if (win == -1) {
|
if (win == -1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
win_text(win, stringList, stringListLength, windowWidth - 4, 2, 8, a5);
|
win_text(win, stringList, stringListLength, windowWidth - 4, 2, 8, foregroundColor);
|
||||||
win_box(win, 0, 0, windowWidth - 1, windowHeight - 1, colorTable[0]);
|
win_box(win, 0, 0, windowWidth - 1, windowHeight - 1, colorTable[0]);
|
||||||
win_box(win, 1, 1, windowWidth - 2, windowHeight - 2, a5);
|
win_box(win, 1, 1, windowWidth - 2, windowHeight - 2, foregroundColor);
|
||||||
win_draw(win);
|
win_draw(win);
|
||||||
win_get_rect(win, rect);
|
win_get_rect(win, rect);
|
||||||
|
|
||||||
@ -707,7 +706,7 @@ static int create_pull_down(char** stringList, int stringListLength, int x, int
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C80E4
|
// 0x4C80E4
|
||||||
static int process_pull_down(int win, Rect* rect, char** items, int itemsLength, int a5, int a6, MenuBar* menuBar, int pulldownIndex)
|
static int process_pull_down(int win, Rect* rect, char** items, int itemsLength, int foregroundColor, int backgroundColor, MenuBar* menuBar, int pulldownIndex)
|
||||||
{
|
{
|
||||||
// TODO: Incomplete.
|
// TODO: Incomplete.
|
||||||
return -1;
|
return -1;
|
||||||
@ -843,7 +842,7 @@ static void win_debug_delete(int btn, int keyCode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C8A54
|
// 0x4C8A54
|
||||||
int win_register_menu_bar(int win, int x, int y, int width, int height, int borderColor, int backgroundColor)
|
int win_register_menu_bar(int win, int x, int y, int width, int height, int foregroundColor, int backgroundColor)
|
||||||
{
|
{
|
||||||
Window* window = GNW_find(win);
|
Window* window = GNW_find(win);
|
||||||
|
|
||||||
@ -880,17 +879,17 @@ int win_register_menu_bar(int win, int x, int y, int width, int height, int bord
|
|||||||
menuBar->rect.lrx = right - 1;
|
menuBar->rect.lrx = right - 1;
|
||||||
menuBar->rect.lry = bottom - 1;
|
menuBar->rect.lry = bottom - 1;
|
||||||
menuBar->pulldownsLength = 0;
|
menuBar->pulldownsLength = 0;
|
||||||
menuBar->borderColor = borderColor;
|
menuBar->foregroundColor = foregroundColor;
|
||||||
menuBar->backgroundColor = backgroundColor;
|
menuBar->backgroundColor = backgroundColor;
|
||||||
|
|
||||||
win_fill(win, x, y, width, height, backgroundColor);
|
win_fill(win, x, y, width, height, backgroundColor);
|
||||||
win_box(win, x, y, right - 1, bottom - 1, borderColor);
|
win_box(win, x, y, right - 1, bottom - 1, foregroundColor);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C8B48
|
// 0x4C8B48
|
||||||
int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int itemsLength, char** items, int a7, int a8)
|
int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int itemsLength, char** items, int foregroundColor, int backgroundColor)
|
||||||
{
|
{
|
||||||
Window* window = GNW_find(win);
|
Window* window = GNW_find(win);
|
||||||
|
|
||||||
@ -930,7 +929,7 @@ int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int ite
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
win_print(win, title, 0, titleX, titleY, window->menuBar->borderColor | 0x2000000);
|
win_print(win, title, 0, titleX, titleY, window->menuBar->foregroundColor | 0x2000000);
|
||||||
|
|
||||||
MenuPulldown* pulldown = &(window->menuBar->pulldowns[window->menuBar->pulldownsLength]);
|
MenuPulldown* pulldown = &(window->menuBar->pulldowns[window->menuBar->pulldownsLength]);
|
||||||
pulldown->rect.ulx = titleX;
|
pulldown->rect.ulx = titleX;
|
||||||
@ -940,8 +939,8 @@ int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int ite
|
|||||||
pulldown->keyCode = keyCode;
|
pulldown->keyCode = keyCode;
|
||||||
pulldown->itemsLength = itemsLength;
|
pulldown->itemsLength = itemsLength;
|
||||||
pulldown->items = items;
|
pulldown->items = items;
|
||||||
pulldown->field_1C = a7;
|
pulldown->foregroundColor = foregroundColor;
|
||||||
pulldown->field_20 = a8;
|
pulldown->backgroundColor = backgroundColor;
|
||||||
|
|
||||||
window->menuBar->pulldownsLength++;
|
window->menuBar->pulldownsLength++;
|
||||||
|
|
||||||
@ -996,15 +995,15 @@ int GNW_process_menu(MenuBar* menuBar, int pulldownIndex)
|
|||||||
pulldown->itemsLength,
|
pulldown->itemsLength,
|
||||||
pulldown->rect.ulx,
|
pulldown->rect.ulx,
|
||||||
menuBar->rect.lry + 1,
|
menuBar->rect.lry + 1,
|
||||||
pulldown->field_1C,
|
pulldown->foregroundColor,
|
||||||
pulldown->field_20,
|
pulldown->backgroundColor,
|
||||||
&rect);
|
&rect);
|
||||||
if (win == -1) {
|
if (win == -1) {
|
||||||
curr_menu = NULL;
|
curr_menu = NULL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyCode = process_pull_down(win, &rect, pulldown->items, pulldown->itemsLength, pulldown->field_1C, pulldown->field_20, menuBar, pulldownIndex);
|
keyCode = process_pull_down(win, &rect, pulldown->items, pulldown->itemsLength, pulldown->foregroundColor, pulldown->backgroundColor, menuBar, pulldownIndex);
|
||||||
if (keyCode < -1) {
|
if (keyCode < -1) {
|
||||||
pulldownIndex = -2 - keyCode;
|
pulldownIndex = -2 - keyCode;
|
||||||
}
|
}
|
||||||
@ -1166,20 +1165,20 @@ int win_input_str(int win, char* dest, int maxLength, int x, int y, int textColo
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculates max length of string needed to represent a1 or a2.
|
// Calculates max length of string needed to represent value1 or value2.
|
||||||
//
|
//
|
||||||
// 0x4C941C
|
// 0x4C941C
|
||||||
static int calc_max_field_chars_wcursor(int a1, int a2)
|
static int calc_max_field_chars_wcursor(int value1, int value2)
|
||||||
{
|
{
|
||||||
char* str = (char*)mem_malloc(17);
|
char* str = (char*)mem_malloc(17);
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(str, 17, "%d", a1);
|
snprintf(str, 17, "%d", value1);
|
||||||
int len1 = strlen(str);
|
int len1 = strlen(str);
|
||||||
|
|
||||||
snprintf(str, 17, "%d", a2);
|
snprintf(str, 17, "%d", value2);
|
||||||
int len2 = strlen(str);
|
int len2 = strlen(str);
|
||||||
|
|
||||||
mem_free(str);
|
mem_free(str);
|
||||||
@ -1276,7 +1275,7 @@ static void tm_kill_msg()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C9B20
|
// 0x4C9B20
|
||||||
static void tm_kill_out_of_order(int a1)
|
static void tm_kill_out_of_order(int queueIndex)
|
||||||
{
|
{
|
||||||
int v7;
|
int v7;
|
||||||
int v6;
|
int v6;
|
||||||
@ -1285,16 +1284,16 @@ static void tm_kill_out_of_order(int a1)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tm_index_active(a1)) {
|
if (!tm_index_active(queueIndex)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
win_delete(tm_queue[a1].id);
|
win_delete(tm_queue[queueIndex].id);
|
||||||
|
|
||||||
tm_location[tm_queue[a1].location].taken = 0;
|
tm_location[tm_queue[queueIndex].location].taken = 0;
|
||||||
|
|
||||||
if (a1 != tm_kill) {
|
if (queueIndex != tm_kill) {
|
||||||
v6 = a1;
|
v6 = queueIndex;
|
||||||
do {
|
do {
|
||||||
v7 = v6 - 1;
|
v7 = v6 - 1;
|
||||||
if (v7 < 0) {
|
if (v7 < 0) {
|
||||||
@ -1321,35 +1320,35 @@ static void tm_kill_out_of_order(int a1)
|
|||||||
static void tm_click_response(int btn)
|
static void tm_click_response(int btn)
|
||||||
{
|
{
|
||||||
int win;
|
int win;
|
||||||
int v3;
|
int queueIndex;
|
||||||
|
|
||||||
if (tm_kill == -1) {
|
if (tm_kill == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
win = win_button_winID(btn);
|
win = win_button_winID(btn);
|
||||||
v3 = tm_kill;
|
queueIndex = tm_kill;
|
||||||
while (win != tm_queue[v3].id) {
|
while (win != tm_queue[queueIndex].id) {
|
||||||
v3++;
|
queueIndex++;
|
||||||
if (v3 == 5) {
|
if (queueIndex == 5) {
|
||||||
v3 = 0;
|
queueIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v3 == tm_kill || !tm_index_active(v3))
|
if (queueIndex == tm_kill || !tm_index_active(queueIndex))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tm_kill_out_of_order(v3);
|
tm_kill_out_of_order(queueIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x4C9C48
|
// 0x4C9C48
|
||||||
static int tm_index_active(int a1)
|
static int tm_index_active(int queueIndex)
|
||||||
{
|
{
|
||||||
if (tm_kill != tm_add) {
|
if (tm_kill != tm_add) {
|
||||||
if (tm_kill >= tm_add) {
|
if (tm_kill >= tm_add) {
|
||||||
if (a1 >= tm_add && a1 < tm_kill)
|
if (queueIndex >= tm_add && queueIndex < tm_kill)
|
||||||
return 0;
|
return 0;
|
||||||
} else if (a1 < tm_kill || a1 >= tm_add) {
|
} else if (queueIndex < tm_kill || queueIndex >= tm_add) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,14 @@ typedef struct MenuBar MenuBar;
|
|||||||
|
|
||||||
typedef void(SelectFunc)(char** items, int index);
|
typedef void(SelectFunc)(char** items, int index);
|
||||||
|
|
||||||
int win_list_select(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int a7);
|
int win_list_select(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int color);
|
||||||
int win_list_select_at(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int a7, int a8);
|
int win_list_select_at(const char* title, char** fileList, int fileListLength, SelectFunc* callback, int x, int y, int color, int start);
|
||||||
int win_get_str(char* dest, int length, const char* title, int x, int y);
|
int win_get_str(char* dest, int length, const char* title, int x, int y);
|
||||||
int win_msg(const char* string, int x, int y, int flags);
|
int win_msg(const char* string, int x, int y, int flags);
|
||||||
int win_pull_down(char** items, int itemsLength, int x, int y, int a5);
|
int win_pull_down(char** items, int itemsLength, int x, int y, int color);
|
||||||
int win_debug(char* string);
|
int win_debug(char* string);
|
||||||
int win_register_menu_bar(int win, int x, int y, int width, int height, int borderColor, int backgroundColor);
|
int win_register_menu_bar(int win, int x, int y, int width, int height, int foregroundColor, int backgroundColor);
|
||||||
int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int itemsLength, char** items, int a7, int a8);
|
int win_register_menu_pulldown(int win, int x, char* title, int keyCode, int itemsLength, char** items, int foregroundColor, int backgroundColor);
|
||||||
void win_delete_menu_bar(int win);
|
void win_delete_menu_bar(int win);
|
||||||
int win_width_needed(char** fileNameList, int fileNameListLength);
|
int win_width_needed(char** fileNameList, int fileNameListLength);
|
||||||
int win_input_str(int win, char* dest, int maxLength, int x, int y, int textColor, int backgroundColor);
|
int win_input_str(int win, char* dest, int maxLength, int x, int y, int textColor, int backgroundColor);
|
||||||
|
Loading…
Reference in New Issue
Block a user