diff --git a/src/input.cc b/src/input.cc index ccfa5a6..1bf56ac 100644 --- a/src/input.cc +++ b/src/input.cc @@ -199,6 +199,13 @@ int inputGetInput() return -1; } +// 0x4C8BC8 +void get_input_position(int* x, int* y) +{ + *x = _input_mx; + *y = _input_my; +} + // 0x4C8BDC void _process_bk() { diff --git a/src/input.h b/src/input.h index 93a0c93..5539af1 100644 --- a/src/input.h +++ b/src/input.h @@ -13,6 +13,7 @@ typedef int(ScreenshotHandler)(int width, int height, unsigned char* buffer, uns int inputInit(int a1); void inputExit(); int inputGetInput(); +void get_input_position(int* x, int* y); void _process_bk(); void enqueueInputEvent(int a1); void inputEventQueueReset(); diff --git a/src/mapper/map_func.cc b/src/mapper/map_func.cc index 0ba769c..92a96fa 100644 --- a/src/mapper/map_func.cc +++ b/src/mapper/map_func.cc @@ -1,6 +1,10 @@ #include "mapper/map_func.h" +#include "color.h" +#include "game_mouse.h" +#include "input.h" #include "memory.h" +#include "mouse.h" #include "proto.h" #include "svga.h" #include "window_manager.h" @@ -22,6 +26,46 @@ void copy_proto_lists() // TODO: Incomplete. } +// 0x4841C4 +void pick_region(Rect* rect) +{ + Rect temp; + int x; + int y; + + gameMouseSetCursor(MOUSE_CURSOR_PLUS); + gameMouseObjectsHide(); + + while (1) { + if (inputGetInput() == -2 + && (mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_DOWN) != 0) { + break; + } + } + + get_input_position(&x, &y); + temp.left = x; + temp.top = y; + temp.right = x; + temp.bottom = y; + + while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) { + inputGetInput(); + + get_input_position(&x, &y); + + if (x != temp.right || y != temp.bottom) { + erase_rect(rect); + sort_rect(rect, &temp); + draw_rect(rect, _colorTable[32747]); + } + } + + erase_rect(rect); + gameMouseSetCursor(MOUSE_CURSOR_ARROW); + gameMouseObjectsShow(); +} + // 0x484294 void sort_rect(Rect* a, Rect* b) { diff --git a/src/mapper/map_func.h b/src/mapper/map_func.h index 843f72a..71517e9 100644 --- a/src/mapper/map_func.h +++ b/src/mapper/map_func.h @@ -7,8 +7,9 @@ namespace fallout { void setup_map_dirs(); void copy_proto_lists(); +void pick_region(Rect* rect); void sort_rect(Rect* a, Rect* b); -void draw_rect(Rect* rect); +void draw_rect(Rect* rect, unsigned char color); void erase_rect(Rect* rect); int toolbar_proto(int type, int id); bool map_toggle_block_obj_viewing_on();