2018-06-17 15:48:42 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
|
|
|
*
|
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
|
|
|
*
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-03-24 20:30:10 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../common.h"
|
|
|
|
#include "../interface/Window.h"
|
|
|
|
#include "../interface/Window_internal.h"
|
|
|
|
|
2018-07-31 17:59:48 +02:00
|
|
|
#include <dukglue/dukglue.h>
|
|
|
|
|
2018-03-24 20:30:10 +01:00
|
|
|
namespace OpenRCT2::Scripting
|
|
|
|
{
|
|
|
|
class ScWindow
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
rct_windowclass _class;
|
|
|
|
rct_windownumber _number;
|
|
|
|
|
|
|
|
public:
|
2018-07-31 17:59:48 +02:00
|
|
|
ScWindow(rct_window* w)
|
2018-05-24 14:49:11 +02:00
|
|
|
: ScWindow(w->classification, w->number)
|
2018-03-25 19:23:24 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-03-24 20:30:10 +01:00
|
|
|
ScWindow(rct_windowclass c, rct_windownumber n)
|
2018-07-31 17:59:48 +02:00
|
|
|
: _class(c)
|
|
|
|
, _number(n)
|
2018-03-24 20:30:10 +01:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-31 17:59:48 +02:00
|
|
|
int32_t x_get()
|
|
|
|
{
|
|
|
|
return GetWindow()->x;
|
|
|
|
}
|
2018-07-31 16:25:50 +02:00
|
|
|
void x_set(int32_t value)
|
2018-03-24 20:30:10 +01:00
|
|
|
{
|
|
|
|
auto w = GetWindow();
|
|
|
|
window_set_position(w, value, w->y);
|
|
|
|
}
|
2018-07-31 17:59:48 +02:00
|
|
|
int32_t y_get()
|
|
|
|
{
|
|
|
|
return GetWindow()->y;
|
|
|
|
}
|
2018-07-31 16:25:50 +02:00
|
|
|
void y_set(int32_t value)
|
2018-03-24 20:30:10 +01:00
|
|
|
{
|
|
|
|
auto w = GetWindow();
|
|
|
|
window_set_position(w, w->x, value);
|
|
|
|
}
|
2018-07-31 17:59:48 +02:00
|
|
|
int32_t width_get()
|
|
|
|
{
|
|
|
|
return GetWindow()->width;
|
|
|
|
}
|
|
|
|
int32_t height_get()
|
|
|
|
{
|
|
|
|
return GetWindow()->height;
|
|
|
|
}
|
2018-03-24 20:30:10 +01:00
|
|
|
bool isSticky_get()
|
|
|
|
{
|
|
|
|
auto flags = GetWindow()->flags;
|
|
|
|
return (flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)) != 0;
|
|
|
|
}
|
|
|
|
|
2018-07-31 17:59:48 +02:00
|
|
|
static void Register(duk_context* ctx)
|
2018-03-24 20:30:10 +01:00
|
|
|
{
|
|
|
|
dukglue_register_property(ctx, &ScWindow::x_get, &ScWindow::x_set, "x");
|
|
|
|
dukglue_register_property(ctx, &ScWindow::y_get, &ScWindow::y_set, "y");
|
|
|
|
dukglue_register_property(ctx, &ScWindow::width_get, nullptr, "width");
|
|
|
|
dukglue_register_property(ctx, &ScWindow::height_get, nullptr, "height");
|
|
|
|
dukglue_register_property(ctx, &ScWindow::isSticky_get, nullptr, "isSticky");
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-07-31 17:59:48 +02:00
|
|
|
rct_window* GetWindow() const
|
2018-03-24 20:30:10 +01:00
|
|
|
{
|
|
|
|
return window_find_by_number(_class, _number);
|
|
|
|
}
|
|
|
|
};
|
2018-07-31 17:59:48 +02:00
|
|
|
} // namespace OpenRCT2::Scripting
|