Add location button to watch window title
This commit is contained in:
@@ -74,11 +74,21 @@ This is usable for any OpenTTD servers
|
||||
|
||||
== CHANGELOG ==
|
||||
|
||||
*** 12.1 (? Oct 2021) ***
|
||||
- Hid new auto-terraforming mode for polyrail behind a setting for now as it is still quite bugged.
|
||||
*** 12.1 (9 Nov 2021) ***
|
||||
- Added company HQ and watch buttons to companies in the online players window.
|
||||
- Made companies clickable in the online players window. Regular click opens company window, Fn(Ctrl)-click opens finances.
|
||||
- Slightly improved the look of online players widow and client list overlay with more informative icons.
|
||||
- Moved company selection to the bottom in the watch window to reduce the waste of a screen space.
|
||||
- Changed main viewport centering button in the watch window to a location button in the window title.
|
||||
- All outgoing actions are queued and not being sent to the server by more than 2 per frame. Should prevent the client from being kicked from most servers when overusing treedozer or copy-paste.
|
||||
- Hid new auto-terraforming mode for polyrail behind a setting for now as it's was quite bugged and confusing. Though all known bugs were fixed so it should quite usable now.
|
||||
- Show both terraforming and autorail highlight when using auto-terraforming polyrail mode.
|
||||
- Fixed client list overlay disappearing after opening console.
|
||||
- Fixed copy-pasting signals.
|
||||
- Fixed auto-terraforming messing remove mode in polyrail tool.
|
||||
- Fixed modifer keys selection in settings ui.
|
||||
- Fixed modifier keys selection in settings ui.
|
||||
- Fixed red highlight on rail tools in remove mode.
|
||||
- Fixed crash when trying to move copied rail out of the map.
|
||||
|
||||
*** 12.0 (17 Oct 2021) ***
|
||||
- Automatically search servers when opening multiplayer window.
|
||||
|
||||
@@ -3,18 +3,22 @@
|
||||
#include "../stdafx.h"
|
||||
|
||||
#include "cm_watch_gui.hpp"
|
||||
|
||||
#include "cm_hotkeys.hpp"
|
||||
#include "cm_main.hpp"
|
||||
|
||||
#include "../widget_type.h"
|
||||
#include "../gfx_type.h"
|
||||
#include "../gfx_func.h"
|
||||
#include "../gui.h"
|
||||
#include "../company_base.h"
|
||||
#include "../company_gui.h"
|
||||
#include "../landscape.h"
|
||||
#include "../map_func.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../viewport_func.h"
|
||||
#include "../window_func.h"
|
||||
#include "../strings_func.h"
|
||||
#include "../zoom_func.h"
|
||||
#include "../map_func.h"
|
||||
|
||||
#include "../network/network.h"
|
||||
#include "../network/network_func.h"
|
||||
@@ -124,6 +128,7 @@ static const NWidgetPart _nested_watch_company_widgets[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, EWW_CAPTION ), SetDataTip(STR_WATCH_WINDOW_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, EWW_LOCATION), SetMinimalSize(12, 14), SetDataTip(SPR_GOTO_LOCATION, CM_STR_WATCH_LOCATION_TOOLTIP),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
@@ -170,6 +175,7 @@ static const NWidgetPart _nested_watch_company_widgetsA[] = {
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_CAPTION, COLOUR_GREY, EWW_CAPTION ), SetDataTip(STR_WATCH_WINDOW_TITLE, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
||||
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, EWW_LOCATION), SetMinimalSize(12, 14), SetDataTip(SPR_GOTO_LOCATION, CM_STR_WATCH_LOCATION_TOOLTIP),
|
||||
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
|
||||
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
||||
@@ -424,6 +430,12 @@ void WatchCompany::OnClick(Point pt, int widget, int click_count)
|
||||
this->owner = this->watched_company;
|
||||
this->SetDirty();
|
||||
}
|
||||
} else if (widget == EWW_LOCATION) {
|
||||
auto x = this->viewport->scrollpos_x + this->viewport->virtual_width / 2;
|
||||
auto y = this->viewport->scrollpos_y + this->viewport->virtual_height / 2;
|
||||
auto pt = InverseRemapCoords(x, y);
|
||||
if (_fn_mod) citymania::ShowExtraViewportWindow(pt.x, pt.y, 0);
|
||||
else ScrollMainWindowTo(pt.x, pt.y, 0);
|
||||
} else if (IsInsideMM(widget, EWW_PB_COMPANY_FIRST, EWW_PB_COMPANY_LAST + 1)) {
|
||||
/* Click on Company Button */
|
||||
if (!this->IsWidgetDisabled(widget)) {
|
||||
@@ -629,7 +641,7 @@ void WatchCompany::ScrollToTile( TileIndex tile )
|
||||
{
|
||||
/* Scroll window to the tile, only if not zero */
|
||||
if (tile != 0) {
|
||||
ScrollWindowTo( TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, -1, this );
|
||||
ScrollWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, -1, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace citymania {
|
||||
|
||||
enum WatchCompanyWidgets {
|
||||
EWW_CAPTION,
|
||||
EWW_LOCATION,
|
||||
EWW_PB_COMPANY_FIRST,
|
||||
EWW_PB_COMPANY_LAST = EWW_PB_COMPANY_FIRST + MAX_COMPANIES - 1,
|
||||
EWW_HAS_CLIENT_FIRST,
|
||||
|
||||
@@ -55,6 +55,9 @@ void ShowStoryBook(CompanyID company, uint16 page_id = INVALID_STORY_PAGE);
|
||||
void ShowEstimatedCostOrIncome(Money cost, int x, int y);
|
||||
|
||||
void ShowExtraViewportWindow(TileIndex tile = INVALID_TILE);
|
||||
namespace citymania {
|
||||
Window *ShowExtraViewportWindow(int x, int y, int z);
|
||||
}
|
||||
void ShowExtraViewportWindowForTileUnderCursor();
|
||||
|
||||
/* bridge_gui.cpp */
|
||||
|
||||
@@ -5978,3 +5978,4 @@ CM_STR_CONFIG_SETTING_ENABLE_POLYRAIL_TERRAFORM :Enable experimental auto-terraf
|
||||
CM_STR_CONFIG_SETTING_ENABLE_POLYRAIL_TERRAFORM_HELPTEXT :Allows to use experimental auto-terraforming mode with polyrail tool (by pressing Fn modifier).
|
||||
CM_STR_NETWORK_CLIENT_LIST_WATCH_TOOLTIP :{BLACK}Watch this company
|
||||
CM_STR_NETWORK_CLIENT_LIST_HQ_TOOLTIP :{BLACK}View company headquarters
|
||||
CM_STR_WATCH_LOCATION_TOOLTIP :{BLACK}Centre the main view on the location. Ctrl+Click opens a new viewport on the location
|
||||
|
||||
@@ -180,6 +180,21 @@ void ShowExtraViewportWindow(TileIndex tile)
|
||||
new ExtraViewportWindow(&_extra_viewport_desc, i, tile);
|
||||
}
|
||||
|
||||
namespace citymania {
|
||||
|
||||
Window *ShowExtraViewportWindow(int x, int y, int z)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
/* find next free window number for extra viewport */
|
||||
while (FindWindowById(WC_EXTRA_VIEWPORT, i) != nullptr) i++;
|
||||
|
||||
auto w = new ExtraViewportWindow(&_extra_viewport_desc, i, INVALID_TILE);
|
||||
if (w) ScrollWindowTo(x, y, 0, w);
|
||||
}
|
||||
|
||||
} // namespace citymania
|
||||
|
||||
/**
|
||||
* Show a new Extra Viewport window.
|
||||
* Center it on the tile under the cursor, if the cursor is inside a viewport.
|
||||
|
||||
Reference in New Issue
Block a user