mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-18 21:43:48 +01:00
implement window_map_tooltip
This commit is contained in:
@@ -110,6 +110,7 @@
|
|||||||
<ClCompile Include="..\src\windows\land.c" />
|
<ClCompile Include="..\src\windows\land.c" />
|
||||||
<ClCompile Include="..\src\windows\main.c" />
|
<ClCompile Include="..\src\windows\main.c" />
|
||||||
<ClCompile Include="..\src\windows\map.c" />
|
<ClCompile Include="..\src\windows\map.c" />
|
||||||
|
<ClCompile Include="..\src\windows\map_tooltip.c" />
|
||||||
<ClCompile Include="..\src\windows\music_credits.c" />
|
<ClCompile Include="..\src\windows\music_credits.c" />
|
||||||
<ClCompile Include="..\src\windows\news.c" />
|
<ClCompile Include="..\src\windows\news.c" />
|
||||||
<ClCompile Include="..\src\windows\new_campaign.c" />
|
<ClCompile Include="..\src\windows\new_campaign.c" />
|
||||||
|
|||||||
@@ -380,7 +380,6 @@
|
|||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
|
||||||
<ClCompile Include="..\src\drawing\rain.c">
|
<ClCompile Include="..\src\drawing\rain.c">
|
||||||
<Filter>Source\Drawing</Filter>
|
<Filter>Source\Drawing</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@@ -390,9 +389,6 @@
|
|||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\libspeex\resample.c">
|
|
||||||
<Filter>Libraries\libspeex</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
<ClCompile Include="..\lib\lodepng\lodepng.c" />
|
||||||
<ClCompile Include="..\lib\libspeex\resample.c">
|
<ClCompile Include="..\lib\libspeex\resample.c">
|
||||||
<Filter>Libraries\lodepng</Filter>
|
<Filter>Libraries\lodepng</Filter>
|
||||||
@@ -428,6 +424,10 @@
|
|||||||
<ClCompile Include="..\src\windows\text_input.c">
|
<ClCompile Include="..\src\windows\text_input.c">
|
||||||
<Filter>Source\Windows</Filter>
|
<Filter>Source\Windows</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
|
||||||
|
<ClCompile Include="..\src\windows\map_tooltip.c">
|
||||||
|
<Filter>Source\Windows</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\src\management\award.h">
|
<ClInclude Include="..\src\management\award.h">
|
||||||
|
|||||||
@@ -57,6 +57,8 @@
|
|||||||
#define RCT2_ADDRESS_LAND_TOOL_SIZE 0x009A9800
|
#define RCT2_ADDRESS_LAND_TOOL_SIZE 0x009A9800
|
||||||
#define RCT2_ADDRESS_SAVE_PROMPT_MODE 0x009A9802
|
#define RCT2_ADDRESS_SAVE_PROMPT_MODE 0x009A9802
|
||||||
|
|
||||||
|
#define RCT2_ADDRESS_MAP_TOOLTIP_ARGS 0x009A9808
|
||||||
|
|
||||||
// #define RCT2_ADDRESS_SCENARIO_LIST 0x009A9FF4
|
// #define RCT2_ADDRESS_SCENARIO_LIST 0x009A9FF4
|
||||||
// #define RCT2_ADDRESS_NUM_SCENARIOS 0x009AA008
|
// #define RCT2_ADDRESS_NUM_SCENARIOS 0x009AA008
|
||||||
|
|
||||||
|
|||||||
@@ -185,8 +185,6 @@ void update_palette_effects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void game_update()
|
void game_update()
|
||||||
{
|
{
|
||||||
int i, numUpdates, tmp;
|
int i, numUpdates, tmp;
|
||||||
@@ -249,8 +247,7 @@ void game_update()
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
RCT2_GLOBAL(0x009AC861, uint16) |= (1 << 2);
|
RCT2_GLOBAL(0x009AC861, uint16) |= (1 << 2);
|
||||||
|
|
||||||
RCT2_CALLPROC_EBPSAFE(0x006EE77A);
|
window_map_tooltip_update_visibility();
|
||||||
|
|
||||||
window_update_all();
|
window_update_all();
|
||||||
|
|
||||||
RCT2_GLOBAL(0x01388698, uint16)++;
|
RCT2_GLOBAL(0x01388698, uint16)++;
|
||||||
|
|||||||
@@ -381,6 +381,7 @@ enum {
|
|||||||
WC_MAP = 38,
|
WC_MAP = 38,
|
||||||
WC_TITLE_LOGO = 39,
|
WC_TITLE_LOGO = 39,
|
||||||
WC_BANNER = 40,
|
WC_BANNER = 40,
|
||||||
|
WC_MAP_TOOLTIP = 41,
|
||||||
WC_EDITOR_OBJECT_SELECTION = 42,
|
WC_EDITOR_OBJECT_SELECTION = 42,
|
||||||
WC_EDITOR_INVENTION_LIST = 43,
|
WC_EDITOR_INVENTION_LIST = 43,
|
||||||
WC_EDITOR_SCENARIO_OPTIONS = 45,
|
WC_EDITOR_SCENARIO_OPTIONS = 45,
|
||||||
@@ -521,6 +522,8 @@ void window_align_tabs( rct_window *w, uint8 start_tab_id, uint8 end_tab_id );
|
|||||||
void window_new_ride_init_vars();
|
void window_new_ride_init_vars();
|
||||||
void window_new_ride_focus(ride_list_item rideItem);
|
void window_new_ride_focus(ride_list_item rideItem);
|
||||||
|
|
||||||
|
void window_map_tooltip_update_visibility();
|
||||||
|
|
||||||
void window_staff_list_init_vars();
|
void window_staff_list_init_vars();
|
||||||
|
|
||||||
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event);
|
void window_event_helper(rct_window* w, short widgetIndex, WINDOW_EVENTS event);
|
||||||
|
|||||||
@@ -276,8 +276,7 @@ void title_update()
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
RCT2_GLOBAL(0x009AC861, uint16) |= 0x04;
|
RCT2_GLOBAL(0x009AC861, uint16) |= 0x04;
|
||||||
|
|
||||||
RCT2_CALLPROC_EBPSAFE(0x006EE77A);
|
window_map_tooltip_update_visibility();
|
||||||
|
|
||||||
window_update_all();
|
window_update_all();
|
||||||
DrawOpenRCT2(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 20);
|
DrawOpenRCT2(0, RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16) - 20);
|
||||||
|
|
||||||
|
|||||||
160
src/windows/map_tooltip.c
Normal file
160
src/windows/map_tooltip.c
Normal file
@@ -0,0 +1,160 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* Copyright (c) 2014 Ted John
|
||||||
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||||
|
*
|
||||||
|
* This file is part of OpenRCT2.
|
||||||
|
*
|
||||||
|
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "../addresses.h"
|
||||||
|
#include "../localisation/localisation.h"
|
||||||
|
#include "../input.h"
|
||||||
|
#include "../interface/widget.h"
|
||||||
|
#include "../interface/window.h"
|
||||||
|
|
||||||
|
static rct_widget window_map_tooltip_widgets[] = {
|
||||||
|
{ WWT_IMGBTN, 0, 0, 199, 0, 29, 0x0FFFFFFFF, STR_NONE },
|
||||||
|
{ WIDGETS_END }
|
||||||
|
};
|
||||||
|
|
||||||
|
static void window_map_tooltip_emptysub() { }
|
||||||
|
static void window_map_tooltip_update(rct_window *w);
|
||||||
|
static void window_map_tooltip_paint();
|
||||||
|
|
||||||
|
static void* window_map_tooltip_events[] = {
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_update,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_emptysub,
|
||||||
|
window_map_tooltip_paint,
|
||||||
|
window_map_tooltip_emptysub
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MAP_TOOLTIP_ARGS
|
||||||
|
|
||||||
|
static int _lastCursorX;
|
||||||
|
static int _lastCursorY;
|
||||||
|
static int _cursorHoldDuration;
|
||||||
|
|
||||||
|
static void window_map_tooltip_open();
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006EE77A
|
||||||
|
*/
|
||||||
|
void window_map_tooltip_update_visibility()
|
||||||
|
{
|
||||||
|
int cursorX, cursorY, inputFlags;
|
||||||
|
|
||||||
|
cursorX = RCT2_GLOBAL(0x0142406C, sint32);
|
||||||
|
cursorY = RCT2_GLOBAL(0x01424070, sint32);
|
||||||
|
inputFlags = RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint8);
|
||||||
|
|
||||||
|
// Check for cursor movement
|
||||||
|
_cursorHoldDuration++;
|
||||||
|
if (abs(cursorX - _lastCursorX) > 5 || abs(cursorY - _lastCursorY) > 5 || (inputFlags & INPUT_FLAG_5))
|
||||||
|
_cursorHoldDuration = 0;
|
||||||
|
|
||||||
|
_lastCursorX = cursorX;
|
||||||
|
_lastCursorY = cursorY;
|
||||||
|
|
||||||
|
// Show or hide tooltip
|
||||||
|
if (
|
||||||
|
_cursorHoldDuration < 25 ||
|
||||||
|
RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, sint16) == -1 ||
|
||||||
|
(RCT2_GLOBAL(RCT2_ADDRESS_PLACE_OBJECT_MODIFIER, uint8) & 3) ||
|
||||||
|
window_find_by_class(WC_ERROR) != NULL
|
||||||
|
) {
|
||||||
|
window_close_by_class(WC_MAP_TOOLTIP);
|
||||||
|
} else {
|
||||||
|
window_map_tooltip_open();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006A7C43
|
||||||
|
*/
|
||||||
|
static void window_map_tooltip_open()
|
||||||
|
{
|
||||||
|
rct_window* w;
|
||||||
|
int x, y, width, height;
|
||||||
|
|
||||||
|
width = 200;
|
||||||
|
height = 44;
|
||||||
|
x = RCT2_GLOBAL(0x0142406C, sint32) - (width / 2);
|
||||||
|
y = RCT2_GLOBAL(0x01424070, sint32) + 15;
|
||||||
|
|
||||||
|
w = window_find_by_class(WC_MAP_TOOLTIP);
|
||||||
|
if (w == NULL) {
|
||||||
|
w = window_create(x, y, width, height, (uint32*)0x009A43D4, WC_MAP_TOOLTIP, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_5);
|
||||||
|
w->widgets = (rct_widget*)0x009DEEFC;
|
||||||
|
} else {
|
||||||
|
window_invalidate(w);
|
||||||
|
w->x = x;
|
||||||
|
w->y = y;
|
||||||
|
w->width = width;
|
||||||
|
w->height = height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006EE8CE
|
||||||
|
*/
|
||||||
|
static void window_map_tooltip_update(rct_window *w)
|
||||||
|
{
|
||||||
|
window_invalidate(w);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* rct2: 0x006EE894
|
||||||
|
*/
|
||||||
|
static void window_map_tooltip_paint()
|
||||||
|
{
|
||||||
|
rct_window *w;
|
||||||
|
rct_drawpixelinfo *dpi;
|
||||||
|
|
||||||
|
window_paint_get_registers(w, dpi);
|
||||||
|
|
||||||
|
if (RCT2_GLOBAL(RCT2_ADDRESS_MAP_TOOLTIP_ARGS, rct_string_id) == (rct_string_id)STR_NONE)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gfx_draw_string_centred_wrapped(dpi, (void*)0x009A9808, w->x + (w->width / 2), w->y + (w->height / 2), w->width, 1162, 0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user