mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-01 14:15:16 +02:00
Add Graphics.resize_window
This commit is contained in:
parent
63442ee5d9
commit
d4dc31af9e
3 changed files with 35 additions and 12 deletions
|
@ -241,6 +241,22 @@ RB_METHOD(graphicsResizeScreen)
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RB_METHOD(graphicsResizeWindow)
|
||||||
|
{
|
||||||
|
RB_UNUSED_PARAM;
|
||||||
|
|
||||||
|
int width, height;
|
||||||
|
bool center = false;
|
||||||
|
rb_get_args(argc, argv, "ii|b", &width, &height, ¢er RB_ARG_END);
|
||||||
|
|
||||||
|
|
||||||
|
GFX_LOCK;
|
||||||
|
shState->graphics().resizeWindow(width, height, center);
|
||||||
|
GFX_UNLOCK;
|
||||||
|
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
RB_METHOD(graphicsReset)
|
RB_METHOD(graphicsReset)
|
||||||
{
|
{
|
||||||
RB_UNUSED_PARAM;
|
RB_UNUSED_PARAM;
|
||||||
|
@ -371,6 +387,7 @@ void graphicsBindingInit()
|
||||||
_rb_define_module_function(module, "fadein", graphicsFadein);
|
_rb_define_module_function(module, "fadein", graphicsFadein);
|
||||||
_rb_define_module_function(module, "snap_to_bitmap", graphicsSnapToBitmap);
|
_rb_define_module_function(module, "snap_to_bitmap", graphicsSnapToBitmap);
|
||||||
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
|
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
|
||||||
|
_rb_define_module_function(module, "resize_window", graphicsResizeWindow);
|
||||||
_rb_define_module_function(module, "center", graphicsCenter);
|
_rb_define_module_function(module, "center", graphicsCenter);
|
||||||
|
|
||||||
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
INIT_GRA_PROP_BIND( Brightness, "brightness" );
|
||||||
|
|
|
@ -1325,9 +1325,6 @@ int Graphics::width() const { return p->scRes.x; }
|
||||||
int Graphics::height() const { return p->scRes.y; }
|
int Graphics::height() const { return p->scRes.y; }
|
||||||
|
|
||||||
void Graphics::resizeScreen(int width, int height) {
|
void Graphics::resizeScreen(int width, int height) {
|
||||||
// width = clamp(width, 1, 640);
|
|
||||||
// height = clamp(height, 1, 480);
|
|
||||||
|
|
||||||
p->threadData->rqWindowAdjust.wait();
|
p->threadData->rqWindowAdjust.wait();
|
||||||
Vec2i size(width, height);
|
Vec2i size(width, height);
|
||||||
|
|
||||||
|
@ -1348,7 +1345,21 @@ void Graphics::resizeScreen(int width, int height) {
|
||||||
|
|
||||||
p->threadData->rqWindowAdjust.set();
|
p->threadData->rqWindowAdjust.set();
|
||||||
shState->eThread().requestWindowResize(width, height);
|
shState->eThread().requestWindowResize(width, height);
|
||||||
update();
|
}
|
||||||
|
|
||||||
|
void Graphics::resizeWindow(int width, int height, bool center) {
|
||||||
|
p->threadData->rqWindowAdjust.wait();
|
||||||
|
//factor = clamp(factor, 0.5, 4.0);
|
||||||
|
|
||||||
|
if (width == p->winSize.x / p->backingScaleFactor &&
|
||||||
|
height == p->winSize.y / p->backingScaleFactor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
p->threadData->rqWindowAdjust.set();
|
||||||
|
shState->eThread().requestWindowResize(width, height);
|
||||||
|
|
||||||
|
if (center)
|
||||||
|
this->center();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Graphics::updateMovieInput(Movie *movie) {
|
bool Graphics::updateMovieInput(Movie *movie) {
|
||||||
|
@ -1518,18 +1529,12 @@ void Graphics::setLastMileScaling(bool value)
|
||||||
double Graphics::getScale() const { return (double)(p->winSize.y / p->backingScaleFactor) / p->scRes.y; }
|
double Graphics::getScale() const { return (double)(p->winSize.y / p->backingScaleFactor) / p->scRes.y; }
|
||||||
|
|
||||||
void Graphics::setScale(double factor) {
|
void Graphics::setScale(double factor) {
|
||||||
p->threadData->rqWindowAdjust.wait();
|
//factor = clamp(factor, 0.5, 4.0);
|
||||||
factor = clamp(factor, 0.5, 4.0);
|
|
||||||
|
|
||||||
if (factor == getScale())
|
|
||||||
return;
|
|
||||||
|
|
||||||
int widthpx = p->scRes.x * factor;
|
int widthpx = p->scRes.x * factor;
|
||||||
int heightpx = p->scRes.y * factor;
|
int heightpx = p->scRes.y * factor;
|
||||||
|
|
||||||
p->threadData->rqWindowAdjust.set();
|
resizeWindow(widthpx, heightpx);
|
||||||
shState->eThread().requestWindowResize(widthpx, heightpx);
|
|
||||||
update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Graphics::getFrameskip() const { return p->useFrameSkip; }
|
bool Graphics::getFrameskip() const { return p->useFrameSkip; }
|
||||||
|
|
|
@ -59,6 +59,7 @@ public:
|
||||||
int width() const;
|
int width() const;
|
||||||
int height() const;
|
int height() const;
|
||||||
void resizeScreen(int width, int height);
|
void resizeScreen(int width, int height);
|
||||||
|
void resizeWindow(int width, int height, bool center=false);
|
||||||
void drawMovieFrame(const THEORAPLAY_VideoFrame* video, Bitmap *videoBitmap);
|
void drawMovieFrame(const THEORAPLAY_VideoFrame* video, Bitmap *videoBitmap);
|
||||||
bool updateMovieInput(Movie *movie);
|
bool updateMovieInput(Movie *movie);
|
||||||
void playMovie(const char *filename, int volume, bool skippable);
|
void playMovie(const char *filename, int volume, bool skippable);
|
||||||
|
|
Loading…
Add table
Reference in a new issue