1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Merge pull request #416 from KingHual/master

Added minimap window resizing
This commit is contained in:
Ted John
2014-09-12 09:04:21 +01:00
5 changed files with 53 additions and 22 deletions

View File

@@ -421,6 +421,8 @@
#define RCT2_ADDRESS_INPUT_QUEUE 0x01424340
#define RCT2_ADDRESS_COMMON_FORMAT_ARGS 0x013CE952
static void RCT2_CALLPROC_EBPSAFE(int address)
{
#ifdef _MSC_VER

View File

@@ -447,7 +447,7 @@ int sub_4015E7(int channel)
int zero = 0;
rct_sound_channel* sound_channel = &RCT2_ADDRESS(0x014262E0, rct_sound_channel)[channel];
LPDIRECTSOUNDBUFFER dsbuffer = RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel];
int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->var_150, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0);
int result = dsbuffer->lpVtbl->Lock(dsbuffer, 0, sound_channel->bufsize, (LPVOID*)&buf1, (LPDWORD)&buf1size, (LPVOID*)&buf2, (LPDWORD)&buf2size, 0);
if (SUCCEEDED(result)) {
if (buf1size) {
mmio_read(sound_channel->hmmio, buf1size, buf1, &sound_channel->mmckinfo1, &read);
@@ -499,11 +499,11 @@ int sound_channel_load_file(int channel, char* filename, int offset)
sound_channel_free(&sound_channel->hmmio, &sound_channel->hmem);
return -103;
}
sound_channel->var_150 = 120 * *((uint32*)sound_channel->hmem + 2) / 100;
sound_channel->bufsize = 120 * *((uint32*)sound_channel->hmem + 2) / 100;
DSBUFFERDESC bufferdesc;
memset(&bufferdesc, 0, sizeof(bufferdesc));
bufferdesc.dwFlags = RCT2_GLOBAL(0x009E1AA8, uint32) | DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY;
bufferdesc.dwBufferBytes = sound_channel->var_150;
bufferdesc.dwBufferBytes = sound_channel->bufsize;
bufferdesc.lpwfxFormat = sound_channel->hmem;
bufferdesc.dwSize = sizeof(bufferdesc);
int ret = RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND)->lpVtbl->CreateSoundBuffer(RCT2_GLOBAL(RCT2_ADDRESS_DIRECTSOUND, LPDIRECTSOUND), &bufferdesc, &RCT2_ADDRESS(RCT2_ADDRESS_DSOUND_BUFFERS, LPDIRECTSOUNDBUFFER)[channel], 0);
@@ -698,10 +698,10 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D
if (dwCurrentPlayCursor >= sound_channel->playpos) {
var1 = dwCurrentPlayCursor - sound_channel->playpos;
} else {
var1 = dwCurrentPlayCursor + sound_channel->var_150 - sound_channel->playpos;
var1 = dwCurrentPlayCursor + sound_channel->bufsize - sound_channel->playpos;
}
if (bufferlost) {
var2 = 2 * sound_channel->var_150 / 6;
var2 = 2 * sound_channel->bufsize / 6;
} else {
var2 = var1;
}
@@ -726,8 +726,8 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D
}
sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
sound_channel->playpos += var2;
if (sound_channel->playpos >= sound_channel->var_150) {
sound_channel->playpos = sound_channel->playpos - sound_channel->var_150;
if (sound_channel->playpos >= sound_channel->bufsize) {
sound_channel->playpos = sound_channel->playpos - sound_channel->bufsize;
}
return;
}
@@ -768,7 +768,7 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D
if (dwCurrentPlayCursor <= sound_channel->playpos) {
sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
} else {
sound_channel->var_15C = sound_channel->playpos + sound_channel->var_150 - dwCurrentPlayCursor;
sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor;
}
goto label49;
}
@@ -795,8 +795,8 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D
label68:
sound_channel->dsbuffer->lpVtbl->Unlock(sound_channel->dsbuffer, buf1, buf1size, buf2, buf2size);
sound_channel->playpos += var2;
if (sound_channel->playpos >= sound_channel->var_150) {
sound_channel->playpos -= sound_channel->var_150;
if (sound_channel->playpos >= sound_channel->bufsize) {
sound_channel->playpos -= sound_channel->bufsize;
}
if (bufferlost != 0) {
sound_channel->dsbuffer->lpVtbl->Play(sound_channel->dsbuffer, 0, 0, DSBPLAY_LOOPING);
@@ -830,7 +830,7 @@ void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, D
if (dwCurrentPlayCursor <= sound_channel->playpos) {
sound_channel->var_15C = sound_channel->playpos - dwCurrentPlayCursor;
} else {
sound_channel->var_15C = sound_channel->playpos + sound_channel->var_150 - dwCurrentPlayCursor;
sound_channel->var_15C = sound_channel->playpos + sound_channel->bufsize - dwCurrentPlayCursor;
}
goto label68;
}

View File

@@ -81,7 +81,7 @@ typedef struct {
MMCKINFO mmckinfo1; // 0x124
MMCKINFO mmckinfo2; // 0x138
LPDIRECTSOUNDBUFFER dsbuffer; // 0x14C
uint32 var_150;
uint32 bufsize;
uint32 playpos; // 0x154
uint32 var_158;
uint32 var_15C;

View File

@@ -48,7 +48,7 @@ static void input_mouseover(int x, int y, rct_window *w, int widgetIndex);
static void input_mouseover_widget_check(rct_windowclass windowClass, rct_windownumber windowNumber, int widgetIndex);
static void input_mouseover_widget_flatbutton_invalidate();
void process_mouse_over(int x, int y);
void sub_6ED801(int x, int y);
void process_mouse_tool(int x, int y);
void invalidate_scroll();
static rct_mouse_data* get_mouse_input();
@@ -1546,7 +1546,7 @@ void game_handle_input()
// RCT2_CALLPROC_X(0x006E8655, eax, ebx, 0, 0, 0, 0, 0); // window_process_mouse_input
process_mouse_over(eax, ebx);
//RCT2_CALLPROC_X(0x006ED833, eax, ebx, 0, 0, 0, 0, 0);
sub_6ED801(eax, ebx);
process_mouse_tool(eax, ebx);
//RCT2_CALLPROC_EBPSAFE(0x006ED801);
}
}
@@ -1601,15 +1601,17 @@ static void game_get_next_input(int *x, int *y, int *state)
*
* rct2: 0x006ED801
*/
void sub_6ED801(int x, int y){
if (RCT2_GLOBAL(0x9DE518, uint32) & (1 << 3)){
void process_mouse_tool(int x, int y)
{
if (RCT2_GLOBAL(0x9DE518, uint32) & (1 << 3))
{
rct_window* w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, uint8), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, uint16));
if (w == NULL){
if (!w)
tool_cancel();
}
else{
else
RCT2_CALLPROC_X(w->event_handlers[WE_TOOL_UPDATE], x, y, 0, RCT2_GLOBAL(0x9DE546, uint16), (int)w, 0, 0);
}
}
}

View File

@@ -84,6 +84,9 @@ static void window_map_scrollmousedown();
static void window_map_invalidate();
static void window_map_paint();
static void window_map_scrollpaint();
static void window_map_tooltip();
static void window_map_set_bounds(rct_window* w);
static void window_map_init_map();
static void sub_68C990();
@@ -111,7 +114,7 @@ static void* window_map_events[] = {
window_map_emptysub,
window_map_emptysub,
window_map_emptysub,
(void*)0x0068D140,
window_map_tooltip,
window_map_emptysub,
window_map_emptysub,
window_map_invalidate,
@@ -160,8 +163,10 @@ void window_map_open()
(1 << WIDX_ROTATE_90) |
(1 << WIDX_PEOPLE_STARTING_POSITION);
w->var_020 |= 0x300;
window_init_scroll_widgets(w);
window_map_set_bounds(w);
w->map.rotation = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint16);
window_map_init_map();
@@ -452,6 +457,15 @@ static void window_map_paint()
gfx_draw_string_left(dpi, STR_MAP_SIZE, 0, 0, w->x + 4, w->y + w->widgets[WIDX_MAP_SIZE_SPINNER].top + 1);
}
/*
*
* rct2: 0x0068D140
*/
static void window_map_tooltip()
{
RCT2_GLOBAL(RCT2_ADDRESS_COMMON_FORMAT_ARGS, short) = 0xC55;
}
/**
*
* rct2: 0x0068CF23
@@ -547,4 +561,17 @@ static void sub_68C990()
w_map->scrolls[0].h_left = cx;
w_map->scrolls[0].v_top = dx;
widget_scroll_update_thumbs(w, WIDX_MAP);
}
/**
* ref. by: window_map_scrollmousedown
* rct2: 0x0068D7DC
*/
void window_map_set_bounds(rct_window* w)
{
w->flags |= WF_RESIZABLE; // (1 << 8)
w->min_width = 245;
w->max_width = 800;
w->min_height = 259;
w->max_height = 560;
}