mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-23 14:54:30 +01:00
Merge branch 'master' into ride-window
This commit is contained in:
3456
data/language/swedish.txt
Normal file
3456
data/language/swedish.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -153,6 +153,7 @@
|
||||
<Text Include="..\data\language\hungarian.txt" />
|
||||
<Text Include="..\data\language\polish.txt" />
|
||||
<Text Include="..\data\language\spanish_sp.txt" />
|
||||
<Text Include="..\data\language\swedish.txt" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{D24D94F6-2A74-480C-B512-629C306CE92F}</ProjectGuid>
|
||||
|
||||
@@ -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
|
||||
|
||||
22
src/audio.c
22
src/audio.c
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
166
src/input.c
166
src/input.c
@@ -33,6 +33,7 @@
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "window_tooltip.h"
|
||||
#include "window_dropdown.h"
|
||||
|
||||
POINT _dragPosition;
|
||||
|
||||
@@ -48,7 +49,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();
|
||||
|
||||
@@ -549,6 +550,145 @@ static void input_leftmousedown(int x, int y, rct_window *w, int widgetIndex)
|
||||
}
|
||||
}
|
||||
|
||||
/* rct2: 0x6E8DA7 */
|
||||
void input_state_widget_pressed( int x, int y, int state, int widgetIndex, rct_window* w, rct_widget* widget ){
|
||||
//RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
//return;
|
||||
RCT2_GLOBAL(0x1420054, uint16) = x;
|
||||
RCT2_GLOBAL(0x1420056, uint16) = y;
|
||||
|
||||
rct_windowclass cursor_w_class;
|
||||
rct_windownumber cursor_w_number;
|
||||
cursor_w_class = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWCLASS, rct_windowclass);
|
||||
cursor_w_number = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WINDOWNUMBER, rct_windownumber);
|
||||
int cursor_widgetIndex = RCT2_GLOBAL(RCT2_ADDRESS_CURSOR_DOWN_WIDGETINDEX, uint32);
|
||||
|
||||
rct_window* cursor_w = window_find_by_id(cursor_w_class, cursor_w_number);
|
||||
if (!cursor_w){
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch (state){
|
||||
case 0:
|
||||
if (!w || cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
|
||||
break;
|
||||
|
||||
if (w->disabled_widgets & (1ULL << widgetIndex))
|
||||
break;
|
||||
|
||||
if (RCT2_GLOBAL(0x9DE528, uint16) != 0) RCT2_GLOBAL(0x9DE528, uint16)++;
|
||||
|
||||
if (w->var_020 & (1ULL << widgetIndex) &&
|
||||
RCT2_GLOBAL(0x9DE528, uint16) >= 0x10 &&
|
||||
(!(RCT2_GLOBAL(0x9DE528, uint16) & 0x3))){
|
||||
RCT2_CALLPROC_WE_MOUSE_DOWN(w->event_handlers[WE_MOUSE_DOWN], widgetIndex, w, widget);
|
||||
}
|
||||
|
||||
if (RCT2_GLOBAL(0x9DE518, uint32) & 1) return;
|
||||
|
||||
RCT2_GLOBAL(0x9DE518, uint32) |= 1;
|
||||
widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex);
|
||||
return;
|
||||
case 3:
|
||||
case 2:
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) == 5){
|
||||
if (w) {
|
||||
int dropdown_index = 0;
|
||||
|
||||
if (w->classification == WC_DROPDOWN){
|
||||
dropdown_index = dropdown_index_from_point(x, y, w);
|
||||
if (dropdown_index == -1)goto dropdown_cleanup;
|
||||
|
||||
// _dropdown_unknown?? highlighted?
|
||||
if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))goto dropdown_cleanup;
|
||||
|
||||
// gDropdownItemsFormat[dropdown_index] will not work until all windows that use dropdown decompiled
|
||||
if (RCT2_ADDRESS(0x9DEBA4, uint16)[dropdown_index] == 0)goto dropdown_cleanup;
|
||||
}
|
||||
else{
|
||||
if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
|
||||
goto dropdown_cleanup;
|
||||
dropdown_index = -1;
|
||||
if (RCT2_GLOBAL(0x9DE518, uint32) & 2){
|
||||
if (!(RCT2_GLOBAL(0x9DE518, uint32) & 4)){
|
||||
RCT2_GLOBAL(0x9DE518, uint32) |= (1 << 2);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window_close_by_id(WC_DROPDOWN, 0);
|
||||
cursor_w = window_find_by_id(cursor_w_class, cursor_w_number);
|
||||
if (RCT2_GLOBAL(0x9DE518, uint32) & 1){
|
||||
RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE;
|
||||
widget_invalidate(cursor_w_class, cursor_w_number, cursor_widgetIndex);
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = cursor_widgetIndex;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_CLASS, rct_windowclass) = cursor_w_class;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WINDOW_NUMBER, rct_windownumber) = cursor_w_number;
|
||||
RCT2_CALLPROC_X(cursor_w->event_handlers[WE_DROPDOWN], dropdown_index, 0, 0, cursor_widgetIndex, (int)cursor_w, 0, 0);
|
||||
}
|
||||
dropdown_cleanup:
|
||||
window_close_by_id(WC_DROPDOWN, 0);
|
||||
}
|
||||
if (state == 3) return;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 1;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_TIMEOUT, uint16) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_TOOLTIP_WIDGET_INDEX, uint16) = cursor_widgetIndex;
|
||||
|
||||
if (!w)
|
||||
break;
|
||||
|
||||
int mid_point_x = (widget->left + widget->right) / 2 + w->x;
|
||||
sound_play_panned(5, mid_point_x);
|
||||
if (cursor_w_class != w->classification || cursor_w_number != w->number || widgetIndex != cursor_widgetIndex)
|
||||
break;
|
||||
|
||||
if (w->disabled_widgets & (1ULL << widgetIndex))
|
||||
break;
|
||||
|
||||
widget_invalidate(cursor_w_class, cursor_w_number, widgetIndex);
|
||||
window_event_helper(w, widgetIndex, WE_MOUSE_UP);
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
RCT2_GLOBAL(0x9DE528, uint16) = 0;
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) != 5){
|
||||
// Hold down widget and drag outside of area??
|
||||
if (RCT2_GLOBAL(0x9DE518, uint32) & 1){
|
||||
RCT2_GLOBAL(0x9DE518, uint32) &= 0xFFFE;
|
||||
widget_invalidate(cursor_w_class, cursor_w_number, cursor_widgetIndex);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!w) return;
|
||||
|
||||
if (w->classification == WC_DROPDOWN){
|
||||
int dropdown_index = dropdown_index_from_point(x, y, w);
|
||||
|
||||
if (dropdown_index == -1) return;
|
||||
|
||||
// _dropdown_unknown?? highlighted?
|
||||
if (dropdown_index < 32 && RCT2_GLOBAL(0x009DED34, sint32) & (1 << dropdown_index))return;
|
||||
|
||||
// gDropdownItemsFormat[dropdown_index] will not work until all windows that use dropdown decompiled
|
||||
if (RCT2_ADDRESS(0x9DEBA4, uint16)[dropdown_index] == 0)return;
|
||||
|
||||
// _dropdown_highlighted_index
|
||||
RCT2_GLOBAL(0x009DEBA2, sint16) = dropdown_index;
|
||||
window_invalidate_by_id(WC_DROPDOWN, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006E8655
|
||||
@@ -612,7 +752,8 @@ static void game_handle_input_mouse(int x, int y, int state)
|
||||
|
||||
break;
|
||||
case INPUT_STATE_WIDGET_PRESSED:
|
||||
RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
input_state_widget_pressed(x, y, state, widgetIndex, w, widget);
|
||||
//RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
break;
|
||||
case INPUT_STATE_DRAGGING:
|
||||
// RCT2_CALLPROC_X(0x006E8C5C, x, y, state, widgetIndex, w, widget, 0);
|
||||
@@ -728,7 +869,8 @@ static void game_handle_input_mouse(int x, int y, int state)
|
||||
break;
|
||||
}
|
||||
case INPUT_STATE_DROPDOWN_ACTIVE:
|
||||
RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
input_state_widget_pressed(x, y, state, widgetIndex, w, widget);
|
||||
//RCT2_CALLPROC_X(0x006E8DA7, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
break;
|
||||
case INPUT_STATE_VIEWPORT_LEFT:
|
||||
//RCT2_CALLPROC_X(0x006E87B4, x, y, state, widgetIndex, (int)w, (int)widget, 0);
|
||||
@@ -756,7 +898,7 @@ static void game_handle_input_mouse(int x, int y, int state)
|
||||
}
|
||||
else if (state == 2){
|
||||
|
||||
RCT2_GLOBAL(0x9DE51D, uint8) = 0;
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_INPUT_STATE, uint8) = 0;
|
||||
if (RCT2_GLOBAL(0x9DE52E, rct_windownumber) != w->number)break;
|
||||
if ((RCT2_GLOBAL(0x9DE518, uint32)&(1 << 3))){
|
||||
w = window_find_by_id(RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWCLASS, rct_windowclass), RCT2_GLOBAL(RCT2_ADDRESS_TOOL_WINDOWNUMBER, rct_windownumber));
|
||||
@@ -1546,7 +1688,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 +1743,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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,8 @@ const char *language_names[LANGUAGE_COUNT] = {
|
||||
"Fran\u00E7ais", // LANGUAGE_FRENCH
|
||||
"Magyar", // LANGUAGE_HUNGARIAN
|
||||
"Polski", // LANGUAGE_POLISH
|
||||
"Espa\u00F1ol" // LANGUAGE_SPANISH
|
||||
"Espa\u00F1ol", // LANGUAGE_SPANISH
|
||||
"Svenska" // LANGUAGE_SWEDISH
|
||||
};
|
||||
|
||||
const char *language_filenames[LANGUAGE_COUNT] = {
|
||||
@@ -43,7 +44,8 @@ const char *language_filenames[LANGUAGE_COUNT] = {
|
||||
"french", // LANGUAGE_FRENCH
|
||||
"hungarian", // LANGUAGE_HUNGARIAN
|
||||
"polish", // LANGUAGE_POLISH
|
||||
"spanish_sp" // LANGUAGE_SPANISH
|
||||
"spanish_sp", // LANGUAGE_SPANISH
|
||||
"swedish" // LANGUAGE_SWEDISH
|
||||
};
|
||||
|
||||
int gCurrentLanguage = LANGUAGE_UNDEFINED;
|
||||
|
||||
@@ -33,6 +33,7 @@ enum {
|
||||
LANGUAGE_HUNGARIAN,
|
||||
LANGUAGE_POLISH,
|
||||
LANGUAGE_SPANISH,
|
||||
LANGUAGE_SWEDISH,
|
||||
LANGUAGE_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -658,7 +658,8 @@ void window_invalidate(rct_window *window)
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EC3AC
|
||||
*
|
||||
* See also widget_invalidate that will probably be used
|
||||
* when cls is > 0x7F.
|
||||
* @param cls (ax)
|
||||
* @param number (bx)
|
||||
*/
|
||||
|
||||
30
src/window.h
30
src/window.h
@@ -516,27 +516,27 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct
|
||||
__asm mov dpi, edi
|
||||
#else
|
||||
#define window_get_register(w) \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_widget_get_registers(w, widgetIndex) \
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
__asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_dropdown_get_registers(w, widgetIndex, dropdownIndex) \
|
||||
__asm__ ( "mov %[dropdownIndex], ax " : [dropdownIndex] "+m" (dropdownIndex) ); \
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
__asm__ ( "mov %["#dropdownIndex"], ax " : [dropdownIndex] "+m" (dropdownIndex) ); \
|
||||
__asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_scrollmouse_get_registers(w, x, y) \
|
||||
__asm__ ( "mov %[x], cx " : [x] "+m" (x) ); \
|
||||
__asm__ ( "mov %[y], dx " : [y] "+m" (y) ); \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
__asm__ ( "mov %["#x"], cx " : [x] "+m" (x) ); \
|
||||
__asm__ ( "mov %["#y"], dx " : [y] "+m" (y) ); \
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_tool_get_registers(w, widgetIndex, x, y) \
|
||||
__asm__ ( "mov %[x], ax " : [x] "+m" (x) ); \
|
||||
__asm__ ( "mov %[y], bx " : [y] "+m" (y) ); \
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
__asm__ ( "mov %["#x"], ax " : [x] "+m" (x) ); \
|
||||
__asm__ ( "mov %["#y"], bx " : [y] "+m" (y) ); \
|
||||
__asm__ ( "mov %["#widgetIndex"], dx " : [widgetIndex] "+m" (widgetIndex) ); \
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) );
|
||||
|
||||
#define window_textinput_get_registers(w, widgetIndex, result, text) \
|
||||
__asm__ ( "mov %[result], cl " : [result] "+m" (result) ); \
|
||||
@@ -545,8 +545,8 @@ void RCT2_CALLPROC_WE_MOUSE_DOWN(int address, int widgetIndex, rct_window*w, rct
|
||||
__asm__ ( "mov %[text], edi " : [text] "+m" (text) );
|
||||
|
||||
#define window_paint_get_registers(w, dpi) \
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) ); \
|
||||
__asm__ ( "mov %[dpi], edi " : [dpi] "+m" (dpi) );
|
||||
__asm__ ( "mov %["#w"], esi " : [w] "+m" (w) ); \
|
||||
__asm__ ( "mov %["#dpi"], edi " : [dpi] "+m" (dpi) );
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -349,3 +349,33 @@ static void window_dropdown_paint()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* New function based on 6e914e
|
||||
* returns -1 if index is invalid
|
||||
*/
|
||||
int dropdown_index_from_point(int x, int y, rct_window* w){
|
||||
int top = y - w->y - 2;
|
||||
if (top < 0) return -1;
|
||||
|
||||
int left = x - w->x;
|
||||
if (left >= w->width) return -1;
|
||||
left -= 2;
|
||||
if (left < 0) return -1;
|
||||
|
||||
// _dropdown_item_width
|
||||
int column_no = left / RCT2_GLOBAL(0x009DED40, sint32);
|
||||
// _dropdown_no_columns
|
||||
if (column_no >= RCT2_GLOBAL(0x009DED44, sint32)) return -1;
|
||||
|
||||
// _dropdown_item_height
|
||||
int row_no = top / RCT2_GLOBAL(0x9DED3C, uint8);
|
||||
// _dropdown_no_rows
|
||||
if (row_no >= RCT2_GLOBAL(0x009DED48, sint32)) return -1;
|
||||
|
||||
// _dropdown_no_columns
|
||||
int dropdown_index = row_no * RCT2_GLOBAL(0x009DED44, sint32) + column_no;
|
||||
// _dropdown_no_items
|
||||
if (dropdown_index >= RCT2_GLOBAL(0x009DEBA0, sint16)) return -1;
|
||||
|
||||
return dropdown_index;
|
||||
}
|
||||
|
||||
@@ -36,5 +36,6 @@ void window_dropdown_show_text(int x, int y, int extray, uint8 colour, uint8 fla
|
||||
void window_dropdown_show_text_custom_width(int x, int y, int extray, uint8 colour, uint8 flags, int num_items, int width);
|
||||
void window_dropdown_show_image(int x, int y, int extray, uint8 colour, uint8 flags, int numItems, int itemWidth, int itemHeight, int numColumns);
|
||||
void window_dropdown_close();
|
||||
int dropdown_index_from_point(int x, int y, rct_window* w);
|
||||
|
||||
#endif
|
||||
176
src/window_map.c
176
src/window_map.c
@@ -24,6 +24,8 @@
|
||||
#include "string_ids.h"
|
||||
#include "widget.h"
|
||||
#include "window.h"
|
||||
#include "window_scenery.h"
|
||||
#include "viewport.h"
|
||||
|
||||
enum WINDOW_MAP_WIDGET_IDX {
|
||||
WIDX_BACKGROUND,
|
||||
@@ -84,6 +86,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 +116,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 +165,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();
|
||||
@@ -196,28 +203,133 @@ static void window_map_close()
|
||||
*/
|
||||
static void window_map_mouseup()
|
||||
{
|
||||
RCT2_CALLPROC_EBPSAFE(0x0068CFC1);
|
||||
/*short widgetIndex;
|
||||
rct_window *w;
|
||||
//RCT2_CALLPROC_EBPSAFE(0x0068CFC1);
|
||||
sint16 var_idx;
|
||||
rct_window* var_w;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov widgetIndex, dx
|
||||
#else
|
||||
__asm__ ( "mov %[widgetIndex], dx " : [widgetIndex] "+m" (widgetIndex) );
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
__asm mov w, esi
|
||||
#else
|
||||
__asm__ ( "mov %[w], esi " : [w] "+m" (w) );
|
||||
#endif
|
||||
|
||||
|
||||
switch (widgetIndex) {
|
||||
window_widget_get_registers(var_w, var_idx);
|
||||
|
||||
switch (var_idx)
|
||||
{
|
||||
case WIDX_CLOSE:
|
||||
window_close(w);
|
||||
window_close(var_w);
|
||||
break;
|
||||
}*/
|
||||
|
||||
case WIDX_SET_LAND_RIGHTS:
|
||||
window_invalidate(var_w);
|
||||
if (!tool_set(var_w, var_idx, 2)) // jb nullsub_52
|
||||
break;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1;
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) = 2;
|
||||
show_gridlines();
|
||||
show_land_rights();
|
||||
show_construction_rights();
|
||||
break;
|
||||
|
||||
case WIDX_LAND_OWNED_CHECKBOX:
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) ^= 2;
|
||||
|
||||
if (RCT2_GLOBAL(0xF1AD61, sint8) & 2)
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) &= 0xF2;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_LAND_SALE_CHECKBOX:
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) ^= 8;
|
||||
|
||||
if (RCT2_GLOBAL(0xF1AD61, sint8) & 8)
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) &= 0xF8;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_CONSTRUCTION_RIGHTS_OWNED_CHECKBOX:
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) ^= 1;
|
||||
|
||||
if (RCT2_GLOBAL(0xF1AD61, sint8) & 1)
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) &= 0xF1;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_CONSTRUCTION_RIGHTS_SALE_CHECKBOX:
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) ^= 4;
|
||||
|
||||
if (RCT2_GLOBAL(0xF1AD61, sint8) & 4)
|
||||
RCT2_GLOBAL(0xF1AD61, sint8) &= 0xF4;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_LAND_TOOL_SMALLER:
|
||||
--RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) < 1)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_LAND_TOOL_LARGER:
|
||||
++RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16);
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) > 7)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 7;
|
||||
|
||||
window_invalidate(var_w);
|
||||
break;
|
||||
|
||||
case WIDX_BUILD_PARK_ENTRANCE:
|
||||
window_invalidate(var_w);
|
||||
if (!tool_set(var_w, var_idx, 2)) // jb nullsub_52
|
||||
break;
|
||||
|
||||
RCT2_GLOBAL(0x9E32D2, sint8) = 0;
|
||||
|
||||
if (!(RCT2_GLOBAL(0x9DE518, sint32) & (1 << 6))) // Remove?
|
||||
RCT2_GLOBAL(0x9DE518, sint32) |= (1 << 6);
|
||||
|
||||
show_gridlines();
|
||||
show_land_rights();
|
||||
show_construction_rights();
|
||||
break;
|
||||
|
||||
case WIDX_ROTATE_90:
|
||||
++window_scenery_rotation;
|
||||
window_scenery_rotation &= 3;
|
||||
break;
|
||||
|
||||
case WIDX_PEOPLE_STARTING_POSITION:
|
||||
if (!tool_set(var_w, var_idx, 2)) // jb nullsub_52
|
||||
break;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 0;
|
||||
|
||||
if (RCT2_GLOBAL(RCT2_ADDRESS_PEEP_SPAWNS, sint16) != -1 && RCT2_GLOBAL(0x13573F8, sint16) != -1)
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_LAND_TOOL_SIZE, sint16) = 1;
|
||||
|
||||
show_gridlines();
|
||||
show_land_rights();
|
||||
show_construction_rights();
|
||||
break;
|
||||
|
||||
default:
|
||||
if (var_idx >= WIDX_PEOPLE_TAB && var_idx <= WIDX_RIDES_TAB)
|
||||
{
|
||||
var_idx -= WIDX_PEOPLE_TAB;
|
||||
if (var_idx == var_w->selected_tab)
|
||||
break;
|
||||
|
||||
var_w->selected_tab = var_idx;
|
||||
var_w->list_information_type = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,6 +564,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 +668,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;
|
||||
}
|
||||
Reference in New Issue
Block a user