Refactor window_set_location to use rct_window::SetLocation

This commit is contained in:
Matt 2019-06-15 17:01:41 +02:00
parent c677a9681a
commit b046d45c01
No known key found for this signature in database
GPG Key ID: 6D4C24A61C93E208
7 changed files with 16 additions and 12 deletions

View File

@ -529,7 +529,7 @@ private:
// Prevent scroll adjustment due to window placement when in-game
auto oldScreenFlags = gScreenFlags;
gScreenFlags = SCREEN_FLAGS_TITLE_DEMO;
window_set_location(w, x, y, z);
w->SetLocation(x, y, z);
gScreenFlags = oldScreenFlags;
viewport_update_position(w);

View File

@ -20,6 +20,7 @@
#include "actions/LandSetRightsAction.hpp"
#include "audio/audio.h"
#include "interface/Viewport.h"
#include "interface/Window_internal.h"
#include "localisation/Localisation.h"
#include "localisation/LocalisationService.h"
#include "management/NewsItem.h"
@ -86,7 +87,7 @@ namespace Editor
gS6Info.category = SCENARIO_CATEGORY_OTHER;
viewport_init_all();
rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN);
window_set_location(mainWindow, 2400, 2400, 112);
mainWindow->SetLocation(2400, 2400, 112);
load_palette();
gScreenAge = 0;
gScenarioName = language_get_string(STR_MY_NEW_SCENARIO);
@ -162,7 +163,7 @@ namespace Editor
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
viewport_init_all();
rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN);
window_set_location(mainWindow, 2400, 2400, 112);
mainWindow->SetLocation(2400, 2400, 112);
load_palette();
}
@ -183,7 +184,7 @@ namespace Editor
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
viewport_init_all();
rct_window* mainWindow = context_open_window_view(WV_EDITOR_MAIN);
window_set_location(mainWindow, 2400, 2400, 112);
mainWindow->SetLocation(2400, 2400, 112);
load_palette();
}

View File

@ -27,6 +27,7 @@
#include "../drawing/Font.h"
#include "../interface/Chat.h"
#include "../interface/Colour.h"
#include "../interface/Window_internal.h"
#include "../localisation/Localisation.h"
#include "../management/Finance.h"
#include "../management/Research.h"
@ -907,7 +908,7 @@ static int32_t cc_set(InteractiveConsole& console, const arguments_t& argv)
int32_t x = (int16_t)(int_val[0] * 32 + 16);
int32_t y = (int16_t)(int_val[1] * 32 + 16);
int32_t z = tile_element_height(x, y);
window_set_location(w, x, y, z);
w->SetLocation(x, y, z);
viewport_update_position(w);
console.Execute("get location");
}

View File

@ -836,12 +836,6 @@ void window_scroll_to_viewport(rct_window* w)
window_scroll_to_location(mainWindow, x, y, z);
}
void window_set_location(rct_window* w, int32_t x, int32_t y, int32_t z)
{
window_scroll_to_location(w, x, y, z);
w->flags &= ~WF_SCROLLING_TO_LOCATION;
}
/**
*
* rct2: 0x006E7C9C

View File

@ -631,7 +631,6 @@ void window_push_others_below(rct_window* w1);
rct_window* window_get_main();
void window_set_location(rct_window* w, int32_t x, int32_t y, int32_t z);
void window_scroll_to_viewport(rct_window* w);
void window_scroll_to_location(rct_window* w, int32_t x, int32_t y, int32_t z);
void window_rotate_camera(rct_window* w, int32_t direction);

View File

@ -0,0 +1,7 @@
#include "Window_internal.h"
void rct_window::SetLocation(int32_t newX, int32_t newY, int32_t newZ)
{
window_scroll_to_location(this, newX, newY, newZ);
flags &= ~WF_SCROLLING_TO_LOCATION;
}

View File

@ -101,6 +101,8 @@ struct rct_window
uint8_t colours[6]; // 0x4BA
uint8_t visibility; // VISIBILITY_CACHE
uint16_t viewport_smart_follow_sprite; // Smart following of sprites. Handles setting viewport target sprite etc
void SetLocation(int32_t x, int32_t y, int32_t z);
};
// rct2: 0x01420078