Start working on ScreenResizer

This commit is contained in:
Inori 2019-08-03 12:33:35 -04:00 committed by Inori
parent 88cdb903fa
commit fd248709e3
2 changed files with 283 additions and 279 deletions

View file

@ -1,23 +1,23 @@
/*
** graphics-binding.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp 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 2 of the License, or
** (at your option) any later version.
**
** mkxp 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 mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
** graphics-binding.cpp
**
** This file is part of mkxp.
**
** Copyright (C) 2013 Jonas Kulla <Nyocurio@gmail.com>
**
** mkxp 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 2 of the License, or
** (at your option) any later version.
**
** mkxp 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 mkxp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "graphics.h"
#include "sharedstate.h"
@ -68,34 +68,34 @@ RB_METHOD(graphicsFrameReset)
}
#define DEF_GRA_PROP_I(PropName) \
RB_METHOD(graphics##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
return rb_fix_new(shState->graphics().get##PropName()); \
} \
RB_METHOD(graphics##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
int value; \
rb_get_args(argc, argv, "i", &value RB_ARG_END); \
shState->graphics().set##PropName(value); \
return rb_fix_new(value); \
}
RB_METHOD(graphics##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
return rb_fix_new(shState->graphics().get##PropName()); \
} \
RB_METHOD(graphics##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
int value; \
rb_get_args(argc, argv, "i", &value RB_ARG_END); \
shState->graphics().set##PropName(value); \
return rb_fix_new(value); \
}
#define DEF_GRA_PROP_B(PropName) \
RB_METHOD(graphics##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
return rb_bool_new(shState->graphics().get##PropName()); \
} \
RB_METHOD(graphics##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
bool value; \
rb_get_args(argc, argv, "b", &value RB_ARG_END); \
shState->graphics().set##PropName(value); \
return rb_bool_new(value); \
}
RB_METHOD(graphics##Get##PropName) \
{ \
RB_UNUSED_PARAM; \
return rb_bool_new(shState->graphics().get##PropName()); \
} \
RB_METHOD(graphics##Set##PropName) \
{ \
RB_UNUSED_PARAM; \
bool value; \
rb_get_args(argc, argv, "b", &value RB_ARG_END); \
shState->graphics().set##PropName(value); \
return rb_bool_new(value); \
}
RB_METHOD(graphicsWidth)
{
@ -204,8 +204,8 @@ DEF_GRA_PROP_B(ShowCursor)
#define INIT_GRA_PROP_BIND(PropName, prop_name_s) \
{ \
_rb_define_module_function(module, prop_name_s, graphics##Get##PropName); \
_rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \
_rb_define_module_function(module, prop_name_s, graphics##Get##PropName); \
_rb_define_module_function(module, prop_name_s "=", graphics##Set##PropName); \
}
void graphicsBindingInit()
@ -221,9 +221,10 @@ void graphicsBindingInit()
INIT_GRA_PROP_BIND( FrameRate, "frame_rate" );
INIT_GRA_PROP_BIND( FrameCount, "frame_count" );
#ifndef USE_ESSENTIALS_FIXES
if (rgssVer >= 2)
{
#endif
_rb_define_module_function(module, "width", graphicsWidth);
_rb_define_module_function(module, "height", graphicsHeight);
_rb_define_module_function(module, "wait", graphicsWait);
@ -233,7 +234,9 @@ void graphicsBindingInit()
_rb_define_module_function(module, "resize_screen", graphicsResizeScreen);
INIT_GRA_PROP_BIND( Brightness, "brightness" );
#ifndef USE_ESSENTIALS_FIXES
}
#endif
if (rgssVer >= 3)
{

View file

@ -4,7 +4,6 @@
#include <ruby.h>
#include <SDL.h>
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
#include <SDL_syswm.h>
#include "sharedstate.h"
#endif
@ -188,36 +187,32 @@ MiniFFI_call(int argc, VALUE *argv, VALUE self)
unsigned long ret;
#if defined(__WIN32__) && defined(USE_ESSENTIALS_FIXES)
// On Windows, if essentials fixes are enabled, function calls that
// do not work with MKXP will be intercepted here so that the code
// still has its desired effect
// On Windows, if essentials fixes are enabled, function calls that
// do not work with MKXP will be intercepted here so that the code
// still has its desired effect
// GetCurrentThreadId, GetWindowThreadProcessId, FindWindowEx,
// and GetForegroundWindow are used for determining whether to
// handle input and for positioning
// GetCurrentThreadId, GetWindowThreadProcessId, FindWindowEx,
// and GetForegroundWindow are used for determining whether to
// handle input and for positioning
// It's a super janky system, but I must abide by it
SDL_SysWMinfo wm;
// It's a super janky system, but I must abide by it
char *fname = RSTRING_PTR(rb_iv_get(self, "_funcname"));
#define func_is(x) !strcmp(fname, x)
#define if_func_is(x) if (func_is(x))
#define func_is(x) !strcmp(fname, x)
#define if_func_is(x) if (func_is(x))
if (func_is("GetCurrentThreadId") || func_is("GetWindowThreadProcessId"))
{
ret = 571; // Dummy
}
else if_func_is("FindWindowEx")
{
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
ret = (unsigned long)wm.info.win.window;
ret = 571;
}
else if_func_is("GetForegroundWindow")
{
if (SDL_GetWindowFlags(shState->sdlWindow()) & SDL_WINDOW_INPUT_FOCUS)
{
SDL_GetWindowWMInfo(shState->sdlWindow(), &wm);
ret = (unsigned long)wm.info.win.window;
ret = 571;
}
else
ret = 0;
@ -243,6 +238,12 @@ MiniFFI_call(int argc, VALUE *argv, VALUE self)
output[1] = y;
ret = true;
}
else if_func_is("SetWindowPos")
{
SDL_SetWindowSize(shState->sdlWindow(),params[4],params[5]-24);
SDL_SetWindowPosition(shState->sdlWindow(),params[2],params[3]);
return true;
}
else
{
ret = (unsigned long)ApiFunction(param);